initiality conjecture

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Type theory
+-- {: .hide}
[[!include type theory - contents]]
=--
#### Category theory
+-- {: .hide}
[[!include category theory - contents]]
=--
=--
=--

#Contents#
* table of contents
{:toc}

## Idea

The _initiality conjecture_ in [[type theory]] states that the [[term model]] of a [[type theory]] should be an [[initial object]] in the [[categorical semantics|category of models]] of that type theory. Initiality guarantees that the [[relation between type theory and category theory]] works as expected, hence that formal [[syntax|syntactical]] [[proofs]] in type theory  match theorems in [[categories]] that [[categorical semantics|interpret]] these type theories.

A careful proof of initiality for the special case of the [[calculus of constructions]] was given in [Streicher 91](#Streicher91).  Since then, initiality for more complex type theories (such as [[Martin-Löf dependent type theory]]) has often been treated as established, as a straightforward extension of Streicher’s result, but never written up carefully for a larger theory.

Around 2010, various researchers (notably [Voevodsky 15](#Voevodsky15), [16](#Voevodsky16), [17](#Voevodsky17)) raised the question of whether these extensions really were sufficiently straightforward to consider them established without further proof.  Since then, views on the status of initiality have varied within the field; but the issue has been, at least, a frustrating unresolved point.

A [[proof]] of the initiality conjecture for a full-featured [[Martin-Löf type theory]] is given/announced in [de Boer 20](#deBoer20), [Brunerie-Lumsdaine 20](#BrunerieLumsdaine20).

> (text adapted from [Brunerie-Lumsdaine 20](#BrunerieLumsdaine20))

## Related concepts

* [[relation between type theory and category theory]]

* [[categorical model of dependent types]]

* [[syntax-semantics duality]]

* [[categorical semantics]]

* [[computational trinitarianism]]

* [[Awodey's conjecture]]

## References
  {#References}

A proof of the initiality conjecture for [[Martin-Löf dependent type theory]] is implicit in the proof of its [[generalized algebraic theory|generalized algebraic]] semantics (for more on this see [Uemura 2019](#Uemura19)/[21](#Uemura21) below), due to:

* {#Cartmell1978} [[John Cartmell]], *Generalised Algebraic Theories and Contextual Categories*, PhD thesis, Oxford University (1978) [[[Cartmell-Thesis.pdf:file]]]

* {#Cartmell86} [[John Cartmell]], *Generalised Algebraic Theories and Contextual Categories*, Annals of Pure and Applied Logic, **32** (1986) 209-243  [[doi:10.1016/0168-0072(86)90053-9](http://dx.doi.org/10.1016/0168-0072%2886%2990053-9)]

Proof of the initiality conjecture for the [[calculus of constructions]]:

* {#Streicher91} [[Thomas Streicher]], Chapter 4 of: _Semantics of type theory -- Correctness, completeness and independence results_, Progress in Theoretical Computer Science, Birkhäuser Boston, Inc., Boston, MA, 1991, xii+298 pp., (ISBN:0-8176-3594-7, [doi:10.1007/978-1-4612-0433-6](https://doi.org/10.1007/978-1-4612-0433-6))

Relevance of proof of more general versions of the conjecture was amplified in:

* {#Voevodsky15} [[Vladimir Voevodsky]], _[HoTT is not an interpretation of MLTT into abstract homotopy theory](https://homotopytypetheory.org/2015/01/11/hott-is-not-an-interpretation-of-mltt-into-abstract-homotopy-theory/)_, Jan 2015

  [[Peter Lumsdaine]] ([13 January 2015](https://homotopytypetheory.org/2015/01/11/hott-is-not-an-interpretation-of-mltt-into-abstract-homotopy-theory/#comment-35811)):

  > I am still confident that initiality (for MLTT, and other specific type theories) is a straightforward extension of Streicher’s proof. But I no longer feel that confidence justifies treating it as proven. We can’t be certain that it’s as straightforward as we think it is until someone has actually written it out — carefully, correctly, and publicly, so that multiple sets of eyes can check for errors.

* {#Voevodsky16} [[Vladimir Voevodsky]], _Mathematical theory of type theories and the initiality conjecture_, April 2016 ([pdf](https://www.math.ias.edu/Voevodsky/other/Voevodsky%20Templeton%20proposal.pdf), [[VoevodskyInitialityConjectureProposal.pdf:file]])

* {#Voevodsky17} [[Vladimir Voevodsky]], _Models, Interpretations and the Initiality Conjecture_, talk at _Special session on category theory and type theory_ in honor of Per Martin-Löf on his 75th birthday, August 17–19, 2017, during the [Logic Colloquium 2017](https://www.math-stockholm.se/konferenser-och-akti/logic-in-stockholm-2/logic-colloquium-201/logic-colloquium-2017-august-14-20-1.717648), [pdf](https://www.math.ias.edu/Voevodsky/files/files-annotated/Dropbox/Unfinished_papers/Type_systems/Notes_on_Type_Systems/2017_LC_Martin-Lof_special_session/BSL_extended_abstract.pdf))

Early status reports on the full proof appeared in:

* [[Andrej Bauer]] (with Philipp Haselwarter and [[Peter Lumsdaine]]), _Toward an initiality theorem for general type theories_, talk at _[Types, Homotopy Type theory, and Verification](https://www.him.uni-bonn.de/programs/past-programs/past-trimester-programs/types-sets-constructions/workshop-types-homotopy-type-theory-and-verification/schedule/)_, June 2018 ([abstract](https://www.him.uni-bonn.de/programs/past-programs/past-trimester-programs/types-sets-constructions/workshop-types-homotopy-type-theory-and-verification/schedule), [video recording](https://youtu.be/Bf2v448-3Qg))

* [[Peter LeFanu Lumsdaine]] (joint with Menno de Boer, [[Guillaume Brunerie]] , [[Anders Mörtberg]]), _Formalising the initiality conjecture in Coq_, Göteborg–Stockholm Joint Type Theory Seminar, December 2018 ([pdf](http://peterlefanulumsdaine.com/research/Lumsdaine-2018-Goteborg-Initiality.pdf))

A full [[proof]] of the [[initiality conjecture]] for full [[Martin-Löf type theory]], [[formal proof|formalized]] in [[Agda]], is given/announced in:

* [[Guillaume Brunerie]] (with Menno de Boer, [[Peter Lumsdaine]], [[Anders Mörtberg]]), _A formalization of the initiality conjecture in Agda_, talk at HoTT 2019, Pittsburgh ([pdf](https://guillaumebrunerie.github.io/pdf/initiality.pdf))

* {#deBoer20} Menno de Boer, _A Proof and Formalization of the Initiality Conjecture of Dependent Type Theory_, Stockholm 2020 ([diva2:1431287](https://su.diva-portal.org/smash/record.jsf?pid=diva2%3A1431287), [pdf](https://su.diva-portal.org/smash/get/diva2:1431287/FULLTEXT01.pdf))

* {#BrunerieLumsdaine20} [[Guillaume Brunerie]], [[Peter LeFanu Lumsdaine]] (joint with Menno de Boer, [[Anders Mörtberg]]), _Initiality for Martin-Löf type theory_, [Homotopy Type Theory Electronic Seminar Talks](https://www.uwo.ca/math/faculty/kapulkin/seminars/hottest.html), Sept 10, 2020

and in

* {#Uemura19} [[Taichi Uemura]], _A General Framework for the Semantics of Type Theory_ [[arXiv:1904.04097](https://arxiv.org/abs/1904.04097), talk slides: [pdf](https://hott.github.io/HoTT-2019/conf-slides/Uemura.pdf)]

* {#Uemura21} [[Taichi Uemura]], _Abstract and concrete type theories_, PhD thesis (2021) [[pdf](https://pure.uva.nl/ws/files/62028111/Thesis.pdf), [hdl:11245.1/41ff0b60-64d4-4003-8182-c244a9afab3b](https://hdl.handle.net/11245.1/41ff0b60-64d4-4003-8182-c244a9afab3b)]

> most of those who believed initiality to remain unresolved have been convinced by [Taichi Uemura’s doctoral thesis](Uemura21), which gives a more detailed alternative to [Cartmell’s 1978 proof](#Cartmell1978) for a more structured class of theories called second-order generalized algebraic theories — a class that includes homotopy type theory, cubical type theory, and many other type theories. [Paraphrased from a comment by [[Jon Sterling]], [Jul 19, 2022](https://nforum.ncatlab.org/discussion/14504/open-problems-in-homotopy-type-theory/?Focus=101156#Comment_101156)]

[[!redirects initiality conjectures]]

[[!redirects initiality theorem]]
[[!redirects initiality theorems]]


Initiality Project

# The Initiality Project

* table of contents
{:toc}

## Overview

The Initiality Project is a communal effort to prove an [[initiality theorem]] for a [[dependent type theory]]: that the categorical structure constructed out of the syntax is the [[initial object]] in some category of [[categorical model of dependent types|structured categorical objects]].

## Plans and work

* [[Initiality Project - Overview|Overview]] -- currently a proposal, under discussion.
* [[Initiality Project - Raw Syntax|Raw Syntax]] -- Formally putting symbols together in a careful and well-defined way.
* [[Initiality Project - Type Theory|Type Theory]] -- The "type theory", with rules on how to manipulate raw syntax. The usual notion of judgements with natural deduction.
* [[Initiality Project - Semantics|Semantics]] -- Categorical structures used to model our type theory
* [[Initiality Project - Partial Interpretation|Partial interpretation function]] -- How to arrive at the categorical model from our type theory
* [[Initiality Project - Substitution|Preservation of Substitution]] - Is substitution in the type theory the same as substitution in the semantics?
* [[Initiality Project - Totality|Totality of the interpretation]] - Showing that the partial interpretation functions give rise to a total interpretation function (just a function).
* [[Initiality Project - Term Model|The Term Model]]
* [[Initiality Project - Functor|The interpretation as a functor]]
* [[Initiality Project - Uniqueness|Uniqueness of the interpretation functor]]
* [[Initiality Project - References|References]]
* [[Initiality Project - BibTeX database|BibTeX database]]

### By type former

* [[Initiality Project - Pi-types]]

## Jobs and volunteers

Here are the tasks to be done.  To volunteer for a task, edit the page and put your name after it.  Some tasks have many sub-tasks (e.g. each of the 8-ish rules at [[Initiality Project - Type Theory - Pi-types]] requires its own inductive clause at [[Initiality Project - Totality - Pi-types]]), so feel free to split up the tasks listed below and volunteer at as small a level of granularity as you wish.

* Create skeletons for all the pages and list the tasks to be done ([[Mike Shulman]])
* Define $\alpha$-equivalence and capture-avoiding substitution in [[Initiality Project - Raw Syntax]] ([[John Dougherty]])
* Define a morphism of CwFs in [[Initiality Project - Semantics]] ([[Paolo Capriotti]]).
* Define $\Pi$-type structure on a CwF in [[Initiality Project - Semantics - Pi-types]].
* Write out the equality rules at [[Initiality Project - Type Theory]] ([[Kenji Maillard]]).
* Define signatures to give arities to constants, and write out the constant rules at [[Initiality Project - Type Theory]].
* Write out the $\Pi$-type congruence rules at [[Initiality Project - Type Theory - Pi-types]].
* Prove some admissible rules, etc. at [[Initiality Project - Type Theory]].
* Define the partial interpretation on $\Pi,\lambda,App$ at [[Initiality Project - Partial Interpretation - Pi-types]].
* Prove local totality for the variable rule at [[Initiality Project - Totality]].
* Prove local totality for the mode-switching rule at [[Initiality Project - Totality]].
* Prove local totality for the equality rules at [[Initiality Project - Totality]].
* Prove local totality for $\Pi,\lambda,App$ at [[Initiality Project - Totality - Pi-types]].
* Create, update and maintain a bibliography ([[Initiality Project - References]]), ([[Initiality Project - BibTeX database]] for the project and link it to existing material.
* QUESTION : whether geometric parametrized forms whose sense in sheaves is touched only grammatically is possible ?

## Background links

* [original nForum discussion](https://nforum.ncatlab.org/discussion/8904/a-communal-proof-of-an-initiality-theorem/)
* [n-Category Café announcement](https://golem.ph.utexas.edu/category/2018/09/a_communal_proof_of_an_initial.html)
* [[Initiality Project - Participants|participant list]].  If you would like to participate, simply add your name to the list and join the conversation!  All work will take place publically on nLab pages, nForum discussions, etc.

## Page index

* [[Initiality Project]]
* [[Initiality Project - BibTeX database]]
* [[Initiality Project - Overview]]
* [[Initiality Project - Partial Interpretation]]
* [[Initiality Project - Participants]]
* [[Initiality Project - Pi-types]]
* [[Initiality Project - Raw Syntax]]
* [[Initiality Project - Raw Syntax - Pi-types]]
* [[Initiality Project - References]]
* [[Initiality Project - Semantics]]
* [[Initiality Project - Semantics - Pi-types]]
* [[Initiality Project - Substitution]]
* [[Initiality Project - Term Model]]
* [[Initiality Project - Term Model - Pi-types]]
* [[Initiality Project - Totality]]
* [[Initiality Project - Type Theory]]
* [[Initiality Project - Type Theory - Pi-types]]
* [[Initiality Project - Type Theory - Term equality]]
* [[Initiality Project - Type Theory - Type equality]]
* [[Initiality Project - Uniqueness]]

category: Initiality Project


Initiality Project - BibTeX database

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

A

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#awodey_2018_natural-models-of-homotopy-type-theory} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#awodey_2018_natural-models-of-homotopy-type-theory):

```
@Article{awodey_2018_natural-models-of-homotopy-type-theory,
  author       = {Awodey, Steve},
  title        = {Natural models of homotopy type theory},
  journal      = {Math. Structures Comput. Sci.},
  year         = 2018,
  volume       = 28,
  number       = 2,
  pages        = {241-286},
  fjournal     = {Mathematical Structures in Computer Science. A Journal in the Applications of Categorical, Algebraic and Geometric Methods in Computer Science},
  issn         = {0960-1295},
  mrclass      = {03B15 (03G30 18G55 55U35)},
  mrnumber     = 3742564,
  mrreviewer   = {Fredrik Nordvall Forsberg},
  doi          = {10.1017/S0960129516000268},
  url          = {https://doi.org/10.1017/S0960129516000268},
  eprint       = {1406.3219}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

K

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#kapulkin_2012_the-simplicial-model-of-univalent-foundations} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#kapulkin_2012_the-simplicial-model-of-univalent-foundations):

```
@Misc{kapulkin_2012_the-simplicial-model-of-univalent-foundations,
  author       = {Kapulkin, Krzysztof and Lumsdaine, Peter LeFanu},
  title	       = {The simplicial model of univalent foundations (after Voevodsky)},
  year	       = 2012,
  note	       = {Revised 2018 as v5},
  eprint       = {1211.2851}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

S

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#streicher_1991_semantics-of-type-theory} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#streicher_1991_semantics-of-type-theory):

```
@Book{streicher_1991_semantics-of-type-theory,
  author       = {Streicher, Thomas},
  title	       = {Semantics of type theory},
  publisher    = {Birkh\"{a}user Boston, Inc., Boston, MA},
  year	       = 1991,
  series       = {Progress in Theoretical Computer Science},
  note	       = {Correctness, completeness and independence results, With a foreword by Martin Wirsing},
  pages	       = {xii+298},
  isbn	       = {0-8176-3594-7},
  mrclass      = {68Q55 (03B40 03B70 03F50 06B35 68Q65)},
  mrnumber     = 1134134,
  mrreviewer   = {John C. Mitchell},
  doi	       = {10.1007/978-1-4612-0433-6},
  url	       = {https://doi.org/10.1007/978-1-4612-0433-6}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

V

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2015_hott-is-not_an-interpretation-of-mltt-into-abstract-homotopy-theory} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#voevodsky_2015_hott-is-not_an-interpretation-of-mltt-into-abstract-homotopy-theory):

```
@Misc{voevodsky_2015_hott-is-not_an-interpretation-of-mltt-into-abstract-homotopy-theory,
  author       = {Voevodsky, Vladimir},
  title        = {HoTT is not an interpretation of MLTT into abstract homotopy theory},
  year         = 2015,
  note         = {Article at the {\url{homotopytypetheory.org}} blog, January 11, 2015},
  url          = {https://homotopytypetheory.org/2015/01/11/hott-is-not-an-interpretation-of-mltt-into-abstract-homotopy-theory/}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2015_from-syntax-to-semantics-of-dependent-type-theories} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#voevodsky_2015_from-syntax-to-semantics-of-dependent-type-theories):

```
@Misc{voevodsky_2015_from-syntax-to-semantics-of-dependent-type-theories,
  author       = {Voevodsky, Vladimir},
  title        = {From syntax to semantics of dependent type theories --- formalized},
  howpublished = {Slides},
  year         = 2015,
  note         = {Lecture at RDP 2015, Warsaw, June 30, 2015},
  url          = {https://www.math.ias.edu/vladimir/sites/math.ias.edu.vladimir/files/2015_06_30_RDP.pdf}
}

```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2016_mathematical-theory-of-type-theories} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#voevodsky_2016_mathematical-theory-of-type-theories):

```
@Misc{voevodsky_2016_mathematical-theory-of-type-theories,
  author       = {Voevodsky, Vladimir},
  title	       = {Mathematical theory of type theories and the initiality conjecture},
  year	       = 2016,
  note	       = {Research proposal to the Templeton Foundation},
  url	       = {https://www.math.ias.edu/Voevodsky/voevodsky-publications_abstracts.html#TempletonProposal}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2017_the-meta-theory-of-dependent-type-theories} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#voevodsky_2017_the-meta-theory-of-dependent-type-theories):

```
@Misc{voevodsky_2017_the-meta-theory-of-dependent-type-theories,
  author       = {Voevodsky, Vladimir},
  title	       = {The meta-theory of dependent type theories},
  howpublished = {Video},
  year	       = 2017,
  note	       = {Members Seminar, Institute for Advanced Study, Princeton, NJ, USA, February 27, 2017},
  url	       = {https://video.ias.edu/membsem/2017/0227-VladimirVoevodsky}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2017_models-interpretations-and-the-initiality-conjectures} BibTeX entry for [this reference](/nlab/show/Initiality+Project+-+References#voevodsky_2017_models-interpretations-and-the-initiality-conjectures):

```
@Misc{voevodsky_2017_models-interpretations-and-the-initiality-conjectures,
  author       = {Voevodsky, Vladimir},
  title	       = {Models, interpretations and the initiality conjectures},
  year	       = 2017,
  note	       = {Lecture at the special session on category theory and type theory in honor of Per Martin-L{\"o}f on his 75th birthday, August 17--19, 2017, during the Logic Colloquium 2017, August 14--20, 2017, Stockholm},
  url	       = {https://www.math.ias.edu/Voevodsky/voevodsky-publications_abstracts.html#logcoll-1}
}
```

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

## See also ##

* [[Initiality Project]]
* [[Initiality Project - References]]

category: Initiality Project

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)


Initiality Project - Overview

# Initiality Project - Overview

This page is part of the [[Initiality Project]].

Here is a proposed slate of choices to make regarding type theories, presentations, definitions, and proof structure.  ("I" refers to [[Mike Shulman]].)  This is only a first proposal and may change; discussion is underway at the nForum [here](https://nforum.ncatlab.org/discussion/9160/initiality-project-plans/).

* table of contents
{: toc}

## The semantics
 {#Semantics}

Of the various ways to describe a [[categorical model of dependent types]], I suggest to use *categories with families*, presented in the style called by [[Steve Awodey|Awodey]] a [natural model](https://arxiv.org/abs/1406.3219), but fully algebraically.  That is, for us a category with families is a (small) [[category]] $C$ together with two [[presheaves]] $Tm,Ty \in [C^{op},Set]$ and a morphism $Tm \to Ty$ that is *algebraically representable* (or, one might say, "represented"): it is equipped with a *function* assigning to each morphism $A:y \Gamma \to Ty$, where $\Gamma\in C$ and $y$ denotes the [[Yoneda embedding]], an object $\Gamma.A\in C$ and a [[pullback square]]
$$\array{ y(\Gamma.A) & \to & Tm \\ \downarrow &&\downarrow \\ y\Gamma & \xrightarrow{A} & Ty. } $$

This is equivalent to the usual notion of category with families (and thereby also to the usual notion of "category with attributes", hence also to discrete or full split comprehension categories).  But, as noted by Awodey, focusing attention on $Tm$ and $Ty$ as objects of $[C^{op},Set]$ has the advantage that the additional structure corresponding to the rules of a type theory are also naturally formulated in $[C^{op},Set]$.  For instance, if $Ty^2$ denotes the domain of the local exponential $(Ty\times Ty \to Ty)^{(Tm\to Ty)}$, then the rules of $\Sigma$-formation and $\Pi$-formation correspond semantically to giving a morphism $Ty^2 \to Ty$.

Note also that $Ty^2$ can be described in the internal extensional type theory of $[C^{op},Set]$ by the context $(A:Ty, B:Tm(A) \to Ty)$; thus $[C^{op},Set]$ is a sort of "semantic [[logical framework]]" for structuring $C$.  My inclination right now is that while we can rely on this for intuition and explanation, we should also formulate all this structure precisely in traditional category-theoretic language, to avoid any appearance of circularity in our construction of categorical models of dependent type theory.

A *morphism of categories with families* is a functor $F:C\to D$ together with a commutative square in $[C^{op},Set]$:
$$\array{ Tm_C & \to & F^*(Tm_D) \\ \downarrow & & \downarrow \\ Ty_C & \to & F^*(Ty_D) }$$
which strictly respects the chosen pullback squares in an appropriate way.  This defines the category $CwF$ in which we hope to construct an initial object.

## The type theory

I suggest to start with a type theory containing only $\Pi$-types.  This seems the simplest situation where we will have to deal with all the basic issues.  We can then add additional structure as desired.

### Axioms

Note that this type theory is completely empty unless we also assert some axioms.  Ideally, I would like the "initiality theorem" to really be a "freeness theorem", saying that the syntactic category of a type theory with axioms is freely generated by those axioms.  Of course, particular axioms can just be added as rules to a theory, but such a general freeness theorem should be parametric over all possible axioms.

Since in a dependent type theory, each axiom can involve previous axioms in its type, it seems that the general semantic formulation will have to involve some kind of a "cell complex" in the category $CwF$.  However, we can leave this to the future for the moment and concentrate on the inductive clauses for interpreting the basic rules of $\Pi$-types.

### Raw syntax

I propose to use syntax with named variables, quotiented by $\alpha$-equivalence.  My reason is that our goal is expositional and sociological, and named variables keep the syntax as close as possible to what "users" of type theory are familiar with.  Since we are humans writing for humans to read, I don't want to deal explicitly with de Bruijn indices, and neither do I want to pretend that we are using de Bruijn indices when we aren't *really* using them.

If this proposal is adopted, then the raw terms for our simple type theory will be inductively generated by:

* Every variable $x$ is a term.
* If $A,B$ are terms and $x$ is a variable, then $\Pi(x:A) B$ is a term.
* If $A,B,M$ are terms and $x$ is a variable, then $\lambda(x:A.B)M$ is a term.
* If $A,B,M,N$ are terms and $x$ is a variable, then $App^{(x:A)B}(M,N)$ is a term.

We define $\alpha$-equivalence which renames bound variables as usual.  Note that the variable $x$ in $\Pi(x:A)B$ scopes only over $B$, in $\lambda(x:A.B)M$ it scopes only over $B$ and $M$, and in $App^{(x:A)B}(M,N)$ it scopes only over $B$.  Capture-avoiding substitution is likewise defined as usual.  Our partial interpretation will be defined recursively over the above inductive definition of terms, and proven to respect $\alpha$-equivalence.

### Bidirectionality

Following Streicher, all our terms are fully (or at least "sufficiently") annotated.  For instance, we write $App^{(x:A)B}(M,N)$ rather than just $App(M,N)$.  (It is, at best, unclear whether any less than fully annotated syntax can be used in an initiality theorem without preprocessing that is tantamount to annotating it.)

In particular, this means that given $\Gamma$ and $t$, if $\Gamma \vdash t:A$ can be derived for any value of $A$, then there is a canonical such $A$ that can be deduced syntactically, or *synthesized*, from $\Gamma$ and $t$.  For instance, if $App^{(x:A)B}(M,N)$ has any type, then it must have the type $B[N/x]$.  On the other hand, the conversion rule implies that $App^{(x:A)B}(M,N)$ must also have any type that is judgmentally *equal* to $B[N/x]$.

Type theorists have a standard technique for distinguishing these two situations, known as [[bidirectional typechecking]].  Instead of one judgment $\Gamma\vdash t:A$, we have two typing judgments:

* $\Gamma \vdash t \Rightarrow A$: in context $\Gamma$ the term $t$ *synthesizes* the type $A$.  Here $A$ is, if it exists, uniquely determined by $\Gamma$ and $t$: it is an "output" to their "inputs".
* $\Gamma \vdash t \Leftarrow A$: in context $\Gamma$ the term $t$ *checks against* the type $A$.  Here $\Gamma$, $t$, and $A$ are all "inputs" and the only "output" is the truth value of whether the typecheck is valid.

There are various advantages of bidirectional typechecking, including:

1. In at least some cases, it permits a formulation of type theory in which only normal forms exist.
1. In at least some cases, it allows omission of annotations, e.g. an un-annotated abstraction $\lambda x.M$ cannot synthesize a type, but it can check against a $\Pi$-type $\Pi(x:A) B$.
1. In at least some cases, it makes it easier to incorporate [[η-expansion]] into an equality-checking algorithm.
1. In at least some cases, it makes derivations of judgments unique, or at least canonical.
1. In at least some cases, it isolates the use of judgmental equality during typechecking in one particular "mode-switching" rule:
   $$ \frac{\Gamma \vdash t \Rightarrow A \qquad \Gamma \vdash A\equiv B}{\Gamma \vdash t \Leftarrow B} $$

(Experts, feel free to add more.)  It is unclear at present whether any of these advantages are relevant to categorical semantics, but by using a bidirectional framework we are better placed to take advantage of them if they do become relevant.  More importantly, it seems to me that the natural structure of the semantic interpretation, as suggested by [[Peter Lumsdaine]] (see below), matches the syntactic bidirectional picture quite closely, and it may be clarifying to make that analogy more precise.

Since all our terms are fully annotated, all of our formation, introduction, and elimination rules can synthesize their types.  However, their *premises* usually involve *checking* their subterms against appropriate types, so the above mode-switching rule gets applied a lot (it is the only way, in our system, to derive a checking judgment).  This might be an issue to want to optimize away in an implementation, but for our semantic purposes it seems irrelevant.

For instance, here are the formation, introduction, and elimination rules for $\Pi$-types:

$$
\frac{\Gamma \vdash A \, type \qquad \Gamma, x:A \vdash B\,type}{\Gamma \vdash \Pi(x:A) B \, type}
$$

$$
\frac{\Gamma \vdash A \, type \qquad \Gamma, x:A \vdash B\,type \qquad \Gamma \vdash M \Leftarrow \Pi(x:A) B \qquad \Gamma \vdash N \Leftarrow A}{\Gamma \vdash App^{(x:A)B}(M,N) \Rightarrow B[N/x]}
$$

$$
\frac{\Gamma \vdash A \, type \qquad \Gamma,x:A \vdash B \,type \qquad \Gamma,x:A \vdash M \Leftarrow B}{\Gamma \vdash \lambda(x:A.B)M \Rightarrow \Pi(x:A) B}
$$

(Note that the "is a type" judgment $\Gamma \vdash A\,type$ is not bidirectional.  With Russell universes we could consider making it so.)

The "hypothesis" rule is that a variable in the context synthesizes its assumed type:

$$\frac{(x:A) \in \Gamma}{\Gamma \vdash x \Rightarrow A.}$$

In implementations of bidirectional typechecking, the equality judgments $\Gamma \vdash s\equiv t : A$ and $\Gamma \vdash A \equiv B \, type$ are sometimes made bidirectional as well.  But at the moment, I don't think there will be is any benefit to us in doing likewise.  In particular, we would like our setup to be general enough to encompass type theories whose judgmental equality is "poorly behaved", e.g. undecidable, such as those with an [[extensional type theory|equality reflection rule]].  Thus the equality judgments should have primitive rules asserting reflexivity, symmetry, transitivity, and congruence properties.

Streicher also includes a basic judgment for equality of *contexts*.  Peter [suggests](https://nforum.ncatlab.org/discussion/8904/a-communal-proof-of-an-initiality-theorem/?Focus=71254#Comment_71254) that that isn't necessary, because

> any contexts that *would* be judgementally equal in the system with that judgement still end up canonically end up judgementally isomorphic, by the substitution that consists of not renaming variables.

I'm inclined to follow Peter's suggestion here, but am open to counterarguments.

Streicher also includes a number of explicit primitive rules involving things like validity of contexts and type-preservation by substitution.  I'm not sure whether these are necessary or not; it seems that maybe by presenting our type theories in "the usual way" we should always be able to ensure that substitution is admissible, even for type theories that are "ill-behaved" in other ways (such as equality reflection).  But maybe there are good reasons to include these rules explicitly?

## The proof

The following proposal for the inductive structure of the argument is based on Streicher's original approach, with a modification suggested by [Peter Lumsdaine](https://nforum.ncatlab.org/discussion/8904/a-communal-proof-of-an-initiality-theorem/?Focus=71254#Comment_71254), and further tweaks to incorporate bidirectionality and build in naturality using the natural-models technology.

### The partial interpretation

Given a finite set of variables $V = \{x_1,\dots,x_n\} \subseteq Var$, the *presheaf of environments* for $V$ is $Tm^V$.  We will define, by structural induction on any term $t$, and any any finite set $V$ of variables, the following partial morphisms of presheaves.

1. $\llbracket t \rrbracket ^V_{type} : Tm^V \rightharpoonup Ty$.
1. $\llbracket t \rrbracket ^V_{\Rightarrow} : Tm^V \rightharpoonup Tm$.
1. $\llbracket t \rrbracket ^V_{\Leftarrow} : Tm^V \times Ty \rightharpoonup Tm$ such that the composite $Tm^V \times Ty \rightharpoonup Tm \to Ty$ is the second projection.

In fact, the third of these is not actually inductive at all: it is simply a semantic counterpart of the bidirectional mode-switching judgment.  We define $\llbracket t \rrbracket ^V_{\Leftarrow}$ to be the domain restriction of
$$ Tm^V \times Ty \xrightarrow{pr_1} Tm^V \overset{\llbracket t \rrbracket ^V_{\Rightarrow}}{\rightharpoonup} Tm $$
to the equalizer of
$$ Tm^V \times Ty \xrightarrow{pr_1} Tm^V \overset{\llbracket t \rrbracket ^V_{\Rightarrow}}{\rightharpoonup} Tm \to Ty $$
and the restriction of the second projection $Tm^V \times Ty$ to its domain.

The other inductive clauses of the partial interpretation should precisely mirror the bidirectional rules of our type theory, using recursive calls to the above three operations as counterparts of the three syntactic judgments $\Gamma \vdash A\,type$, $\Gamma \vdash t\Rightarrow A$, and $\Gamma \vdash t\Leftarrow A$.  Note, though, that at this point this is only an analogy: we are simply inducting over the raw term structure of $t$, not making any actual reference to these judgments.

This suggestion incorporates the innovation proposed by [Peter](https://nforum.ncatlab.org/discussion/8904/a-communal-proof-of-an-initiality-theorem/?Focus=71254#Comment_71254) over Streicher's proof of taking the interpretation of the context $\Gamma$ as an *input* to the partial intepretation functions rather than an output (see in particular his point (7)).  The elements of the presheaf $Tm^V$ at some object $X\in C$ are what Peter calls "environments" for $t$.  Note that we do not require that $V$ contain all free variables occurring in $t$, but if it omits some then the partial interpretation morphisms should turn out to have empty domain.

I have also reformulated the interpretation function to "put naturality into the goals of the original induction" as suggested by Peter in his point (8), by directly defining partial morphisms in the "semantic logical framework" $[C^{op},Set]$.  This has the additional advantage that in writing down the inductive clauses we can refer directly to the natural-models formulation of the corresponding structure on $C$, as sketched [above](#Semantics).

### Totality of the interpretation

Although the partial interpretation functions sketched above incorporate a number of "tweaks" to make it more pleasing, in fact it was already the short part: Streicher does it in only 5 pages.  (His pages are very short, so this isn't actually very much, plus his type theory is more complicated.)  The long part is proving that these interpretation functions are total on derivable judgments; this takes Streicher 40 pages.

The outline should be the same as in Streicher's proof and Peter's proposal:

1. Prove by induction on raw terms that the partial interpretation functions take syntactic substitution (including weakening) to semantic substitution (restriction in the presheaves $Tm$ and $Ty$).  This takes Streicher 17 pages.

1. Prove by induction on derivations that the partial interpretation functions are total on derivable judgments.  This takes Streicher 20 pages.

### Loose ends

To complete the proof of initiality after this, it remains to:

1. Construct the term model.  This takes Streicher 12 pages.

1. Show that the above interpretation assembles into a morphism in $CwF$ from the term model to $C$.  As far as I can tell, Streicher doesn't actually do this, he just claims that it can be done.

1. Show that this morphism is unique.  Streicher doesn't actually do this either.

category: Initiality Project


# Initiality Project - Partial Interpretation

This page is part of the [[Initiality Project]].

* table of contents
{: toc}

## Overview

Let $C$ be a [[Initiality Project - Semantics|category with families]], with presheaves $Ty$ and $Tm$ of "semantic types" and "semantic terms".  Given a finite set of variables $V \subseteq Var$, we define the **presheaf of environments** for $V$ to be $Tm^V$.  We will define, by structural induction on any term $T$, and any any finite set $V$ of variables, the following [[partial morphisms]] of presheaves.

1. $\llbracket T \rrbracket ^V_{type} : Tm^V \rightharpoonup Ty$.
1. $\llbracket T \rrbracket ^V_{\Rightarrow} : Tm^V \rightharpoonup Tm$.
1. $\llbracket T \rrbracket ^V_{\Leftarrow} : Tm^V \times Ty \rightharpoonup Tm$ such that the composite $Tm^V \times Ty \rightharpoonup Tm \to Ty$ is the second projection.

In fact, the third of these is not actually inductive at all: it is simply a semantic counterpart of the bidirectional mode-switching judgment.  We define $\llbracket T \rrbracket ^V_{\Leftarrow}$ to be the domain restriction of
$$ Tm^V \times Ty \xrightarrow{pr_1} Tm^V \overset{\llbracket T \rrbracket ^V_{\Rightarrow}}{\rightharpoonup} Tm $$
to the equalizer of
$$ Tm^V \times Ty \xrightarrow{pr_1} Tm^V \overset{\llbracket T \rrbracket ^V_{\Rightarrow}}{\rightharpoonup} Tm \to Ty $$
and the restriction of the second projection $Tm^V \times Ty$ to its domain.

The inductive clauses of the definitions of $\llbracket T \rrbracket ^V_{type}$ and $\llbracket T \rrbracket ^V_{\Rightarrow}$ will be given below.  This is an induction over *raw syntax*, but the clauses *should* be defined to precisely mirror the bidirectional rules of our [[Initiality Project - Type Theory|type theory]], using recursive calls to the above three operations as counterparts of the three syntactic judgments $\Gamma \vdash A\,type$, $\Gamma \vdash T\Rightarrow A$, and $\Gamma \vdash T\Leftarrow A$ (and checks for semantic equality as a counterpart of the syntactic equality judgments).  This correspondence will then enable the [[Initiality Project - Totality|proof of totality]] to proceed straightforwardly.

## Inductive Clauses

### Variables

If $T$ is a variable $x$, then:

* $\llbracket x \rrbracket ^V_{type}$ is the empty partial function (this might change with Russell universes).
* If $x\notin V$, then $\llbracket x \rrbracket ^V_{\Rightarrow}$ is the empty partial function.
* If $x\in V$, then $\llbracket x \rrbracket ^V_{\Rightarrow} : Tm^V \rightharpoonup Tm$ is the (total) projection onto the $x^{th}$ factor.

### Constants

TODO

### $\Pi$-types

include [[Initiality Project - Partial Interpretation - Pi-types]]

## Contexts
 {#Contexts}

Now that we have interpreted raw terms as semantic terms and semantic types, we can interpret raw contexts as well.  Suppose $\Gamma$ is a raw context, and let $V$ be the finite (ordered) set of variables occuring in $\Gamma$.  We define a sub-presheaf $\llbracket \Gamma \rrbracket \subseteq Tm^V$ by induction on the length of $\Gamma$ as follows.

* For the empty context $()$, we have $\llbracket () \rrbracket = Tm^0 = 1$, the terminal presheaf.
* For an extended context $(\Gamma, x:A)$, with variables $V \cup \{x\}$ where $x\notin V$, we inductively have $\llbracket \Gamma \rrbracket \subseteq Tm^V$.  We also have (as defined above inductively) $\llbracket A \rrbracket^V_{type} : Tm^V \rightharpoonup Ty$.  Let $U$ be the intersection of $\llbracket \Gamma \rrbracket$ and the domain of $\llbracket A \rrbracket^V_{type}$, and let $\llbracket \Gamma, x:A \rrbracket$ be defined by the following pullback, where the bottom arrow is the composite $U \hookrightarrow Tm^V \overset{\llbracket A \rrbracket^V_{type}}{\rightharpoonup} Ty $.
  $$ \array { \llbracket \Gamma, x:A \rrbracket & \to & Tm \\ \downarrow & & \downarrow \\ U & \to & Ty }$$
  We equip it with the composite $\llbracket \Gamma, x:A \rrbracket \to U \times Tm \to Tm^V \times Tm$, which is a composite of two monomorphisms and hence itself a monomorphism.  Thus $\llbracket \Gamma, x:A \rrbracket$ is indeed a sub-presheaf of $Tm^{V\cup \{x\}} \cong Tm^V \times Tm$ as intended.

category: Initiality Project


Initiality Project - Participants

# Initiality Project - Participants

If you would like to participate in the [[Initiality Project]], just add your name to the list, join the conversation, and volunteer to do stuff.

* [[Mike Shulman]] (coordinator)
* [[Richard Williamson]]
* [[Max S. New]]
* [[David Corfield]]
* [[John Dougherty]]
* [[Peter LeFanu Lumsdaine]]
* [[Ali Caglayan]]
* [[Steve Awodey]]
* [[Andre Joyal]]
* [[Benedikt Ahrens]]
* [[Jasper Hugunin]]
* [[Dan Licata]]
* [[Dave Ripley]]
* [[Mitchell Riley]]
* [[Andy Pitts]]
* [[Ulrik Buchholtz]]
* [[Samuel Mimram]]
* [[Paolo Capriotti]]
* [[Rafaël Bocquet]]
* [[András Kovács]]
* [[Favonia]]
* [[Robin Adams]]
* [[Paul Gustafson]]
* [[Anders Mörtberg]]
* [[Neel Krishnaswami]]
* [[Luis Scoccola]]
* [[Sam Speight]]
* [[Vikraman Choudhury]]
* [[Corlin Fardal]]
* [[Kenji Maillard]]
* [[Andrew Swan]]
* [[Stephan Spahn]]
* [[Matthew Weaver]]
* [[Jonathan Weinberger]]
* [[tslil clingman]]
* [[Tamara von Glehn]]
* [[Nicolai Kraus]]
* [[Todd Trimble]]
* [[Simon Huber]]
* [[Andrew Polonsky]]
* [[Thomas Streicher]]
* Matt Oliveri

category: Initiality Project


Initiality Project - Pi-types

# Initiality Project - $\Pi$-types

This page is part of the [[Initiality Project]].

* table of contents
{:toc}

Here we collect all the rules, definitions, and inductive clauses that pertains specifically to $\Pi$-types.

## Raw syntax

[[!include Initiality Project - Raw Syntax - Pi-types]]

## Type theory

[[!include Initiality Project - Type Theory - Pi-types]]

## Semantics

include [[Initiality Project - Semantics - Pi-types]]

## Partial interpretation

include [[Initiality Project - Partial Interpretation - Pi-types]]

## Preservation of substitution

include [[Initiality Project - Substitution - Pi-types]]

## Totality

include [[Initiality Project - Totality - Pi-types]]

## The Term Model

[[!include Initiality Project - Term Model - Pi-types]]

## Interpretation functor

include [[Initiality Project - Functor - Pi-types]]

## Uniqueness

include [[Initiality Project - Uniqueness - Pi-types]]

category: Initiality Project


Initiality Project - Raw Syntax

# Initiality Project - Raw Syntax

This page is part of the [[Initiality Project]].

* table of contexts
{:toc}

## Idea

Here we define the "raw syntax" for our type theory.  These are sets whose elements are called "raw terms" and "raw types".  They are obtained by putting together operations like "$\Sigma$-types" and "$\lambda$-abstraction" in a way that "makes sense locally" but not necessarily globally.

In traditional approaches to logic, one often defines the raw terms (or "well-formed formulas") as a subset of the set of all "[[string (computer science)|strings]]", i.e. finite lists of elements of some "[[alphabet]]" set such as $\{\Sigma,\Pi,\lambda,(,),:,\dots \}$.  Note that parentheses, colons, commas, and so on are all symbols in the alphabet.  In addition, this point of view requires us to alter some of the clauses to include extra parentheses, e.g. we have to write $(A\times B)$ so that $((A\times B)\times C)$ has an unambiguous meaning.

However, a more modern perspective is to regard this as defining an [[inductive type]] (in the metatheory), with each clause as a constructor.  In this case, the raw terms themselves are not lists of symbols with some property, but rather *[[trees]]* whose nodes are labeled with appropriate symbols.  This way we obtain automatically an induction principle for defining functions by recursion and proving theorems by induction over the set of terms, which in the strings-of-symbols approach one has to prove by hand.  The strings of symbols we write on the page like $(A\times B)\times C$ are then regarded as just a *notation* for these "[[abstract syntax tree|abstract syntax trees]]".

It's true that to be completely precise about the *entire* passage from "mathematics written on the page" to its meaning, one would want to also define the strings of symbols and prove that they faithfully represent the syntax trees.  This is analogous to how a compiler for a programming language must start out by "parsing" and "lexing" the code written by the programmer (which is a string of symbols) into an internal "abstract syntax tree" representation.  However, such things are well-understood and extremely uninteresting, so much so that programmers often use "parser generator" programs to *write parsers for them*; the interesting and nontrivial mathematics starts once we have an abstract syntax tree.

## Variables and meta-variables

Experts will know that there are many ways to deal with [[bound variable|variable binding]] in type theory, including "named variables", "[[de Bruijn indices]]", "de Bruijn levels", "locally nameless variables", and so on.  We will use "named variables".  The reason is that our goal is expositional and sociological, and named variables keep the syntax as close as possible to what "users" of type theory are familiar with (e.g. with named variables we write $\lambda x. \lambda y. App(x,y)$, whereas with de Bruijn indices one has to write instead $\lambda. \lambda. App(2,1)$).  Since we are humans writing for humans to read, we don't want to deal explicitly with de Bruijn indices, and neither do we want to pretend that we are using de Bruijn indices when we aren't *really* using them.

Thus, we suppose given an infinite set $Var$, whose elements we call *[[variables]]*.  [[constructive mathematics|Constructivists]] should assume that $Var$ has [[decidable equality]].  In addition we assume given an operation $fr : Var \times P_{fin}(Var) \to Var$ which replaces a variable with another one that is "fresh for", i.e. distinct from all of, a given finite set of variables.  That is, we assume that $fr(x,V) \notin V$.  We also assume for simplicity that if already $x\notin V$ then $fr(x,V) = x$.  We will also write $fr(x,V)$ as $x^{[V]}$, and if $X = \{x_1,\dots,x_n\}$ is a linearly ordered set of variables we will write
$$X^{[V]} = \{ x_1^{[V]}, x_2^{[V\cup \{x_1^{[V]}\}]}, \dots, x_n^{[V \cup \{x_1,\dots,x_{n-1}\}^{[V]}]}\}$$
for the result of freshening each element of $X$ in succession, ensuring that they remain distinct not only from $V$ but also from each other.

We will also frequently use *meta-variables*.  These are simply ordinary mathematical variables in the "metatheory", i.e. the ordinary informal mathematics we are using in which to define and prove things about type theory.  Single upper-case roman letters will usually be meta-variables ranging over raw terms or raw types.  Single lower-case roman letters will usually be meta-variables ranging over variables (i.e. elements of $Var$).

## Sorts, operators, and constants

Overall, we are not attempting in this project to treat "all type theories" at any level of generality, instead simply dealing with individual type formers one by one (though attempting to be as "modular" as possible).  However, at the level of *raw* syntax we can easily be fully general, thereby saving ourselves some additional work in each case.  Thus, we will work with a variant of what in [[Practical Foundations for Programming Languages]] are called *abstract binding trees*, parametrized by a set of *sorts* and a set of *operators*.

For us the set of **sorts** is $Sort = \{ tm, ty \}$.  That is, there are two classes of raw syntactic objects: raw terms and raw types.  The only function of the notion of "sort" is to avoid writing exactly the same things twice in the two cases.

The set of **operators** $Op$ is a parameter of the theory; the rules for each type former begin by specifying some relevant operators.  For instance, the operators associated to $\Pi$-types are $\{ \Pi, \lambda, App\}$.

Each operator is furthermore associated with a **signature** or **generalized arity**, which consists of:

0. A sort (i.e. either $tm$ or $ty$).
1. A natural number $n$, the **argument arity**.
2. A [[function]] from $[n]=\{1,\dots,n\}$ to $Sort$, the **argument sorts**.
3. A natural number $m$, the **binding arity**.
4. A decidable [[relation]] $\lhd$ between $[n]$ and $[m]$ called **scoping**.  If $j\lhd k$ we say that the $j^{th}$ argument is *in the scope of* the $k^{th}$ binder.

Often (e.g. in [[PFPL]]) the scoping relation is a [[function]] from $[m]$ to $[n]$, i.e. each binder has exactly one subterm in its scope.  However, it is convenient to be more general; e.g. in a fully-annotated $\lambda$-abstraction $\lambda(x:A.B).M$ it is natural to consider $B$ and $M$ to be both in the scope of the variable $x$, rather than requiring this to be desugared to a form such as $\lambda(A,x.B,x'.M)$ in which potentially-different variables are bound in $B$ and $M$.  Thus, we will represent $\lambda$ as an operator with 3 arguments, two of sort $ty$ and one of sort $tm$, with binding arity 1, and scoping relations $2\lhd 1$ and $3\lhd 1$.

Fully general abstract binding trees also allow each *binder* to be associated to a sort.  However, in our type theories all variables will range only over terms (not types).

Finally, in addition to the operators arising from type formers, we assume a collection of **constants**, each of which is an operator with binding arity $0$ and all arguments having sort $tm$.

We will usually use single upper-case typewriter font letters like $\mathtt{C},\mathtt{D}$ for meta-variables ranging over operators, including constants.

## Raw terms

Our raw syntax, though untyped, will be *strongly scoped*.  By this we mean that each raw term or type is indexed by a finite set of variables that may occur in it freely.  To be precise, we define inductively a family of sets $Raw$ indexed by $P_{fin}(Var) \times Sort$; we call their elements **raw terms/types with variables from $V$**.  Since we are in such generality, there are only two constructors of this inductive family:

* For any $V\in P_{fin}(Var)$ and any $x\in V$, we have $x\in Raw(V,tm)$.

* Suppose $\mathtt{C}$ is an operator of sort $s$, argument arity $n$ and binding arity $m$.  Suppose also $V, X\in P_{fin}(Var)$, with $V\cap X = \emptyset$, ${|X|} = m$, and $X = \{x_1,\dots, x_m\}$ totally ordered.  Given $j\in [n]$, write $X_j = \{x_k \mid j \lhd k \}$ for the variables bound in argument $j$, and suppose furthermore that for each $j\in [n]$ we have $M_j\in Raw(V\cup X_j, t_j)$, where $t:[n] \to Sort$ gives the argument sorts of $\mathtt{C}$.  Then we have an element $\mathtt{C}(X;\vec{M}) \in Raw(V,s)$.

This can be read as saying that each set $Raw(V,s)$ consists of well-founded rooted trees containing nodes of two kinds:

* Nodes labeled by a variable (element of $Var$) that is either in $V$ or is bound in some parent of that node and scopes over that node.  Such a node has no children and is of sort $tm$.

* Nodes labeled by an operator and a list of variables of its binding arity that are *not* in $V$ or bound in some parent of that node.  Such a node has a number of children equal to the argument arity of its operator label, of appropriate sorts, and each of its variables scopes over the subtrees of those children specified by the scoping relation of its operator label, while its sort is that of its operator label.

The above clauses also introduce notation for these trees: we will write simply "$x$" for the tree consisting of a single variable node with associated variable $x$, and $\mathtt{C}(X;\vec{M})$ for the tree whose root is an operator node with associated operator $\mathtt{C}$, bound variables $X$, and subtrees $\vec{M}$.  (These are the "linear" syntaxes that have to be "parsed" into an abstract syntax tree if implementing type theory on a computer.)  For instance, a fully annotated abstraction $\lambda(x:A.B).M$ is desugared as $\lambda(x;A,B,M)$, a node labeled by $\lambda$ and $x$ with three subtrees, two of which are in the scope of $x$.

The requirement that $V\cap X= \emptyset$ amounts to a "local [[Barendregt convention]]" that the names of bound variables can never clash with (or "shadow") any free variables, where the set of "free variables" is *declared* for each raw term or type (the set $V$) rather than extracted by syntactic analysis.  Maintaining this convention requires "freshening" when we weaken by adding new unused free variables; see below.

## Operators

For each type former, we describe its binding arity, argument arity and sorts, and scoping relation in a hopefully more readable form, by giving arbitrary names to its bound variables and arguments.  We also give the "sugared" or "traditional" syntax that we will usually use for it.

For instance, the $\lambda$ row below means that $\lambda$ is an operator of sort $tm$, it has two arguments of sort $ty$ and one of sort $tm$, and one binder that scopes over the second type argument and the term argument.

### $\Pi$-types

[[!include Initiality Project - Raw Syntax - Pi-types]]

### Others

to be added later...

## Structural induction

The principle of structural induction on raw terms and types says that to prove something about all of them, it suffices to consider raw terms and types constructed according to each of the above clauses (i.e. consider all possible labels for the root of an abstract syntax tree), assuming as an inductive hypothesis that the desired statement holds of all subtrees.  This is a basic property of an inductive type; if our metatheory is set-theoretic then it can be proven from the definition of well-founded tree.

Similarly, there is a structural recursion principle for defining pairs of functions with domains $RawTm$ and $RawTy$: to define such a function it suffices to say, for each inductive clause, how to construct the value of the function on a tree with that root, assuming given its values on all the subtrees.

## $\alpha$-equivalence

We want to identify raw terms and types that differ only according to a renaming of bound variables.  However, in defining this inductively, we end up having to also rename *free* variables in the terms where the variables are bound.  We do this all together by defining a relation $M \sim_\rho M'$, where $M\in Raw(V,s)$, $M'\in Raw(V',s)$, and $\rho$ is a bijection $V\cong V'$, by recursion on $M$ and $M'$ as follows:

* If $x\in V$ and $y\in V'$, then $x \sim_\rho y$ if and only if $\rho(x)=y$.

* For ordered sets $X,X'$ of the same cardinality, let $\xi:X\cong X'$ be the unique order-preserving bijection between them, and with $X_j = \{x_k \mid j \lhd k \}$ and $X'_j = \{x'_k \mid j \lhd k \}$ as before we have similarly $\xi_j : X_j \cong X'_j$.  Then $\mathtt{C}(X;\vec{M}) \sim_{\rho} \mathtt{C}(X';\vec{M'})$ if and only if $M_j \sim_{\rho \cup \xi_j} M'_j$ for all $j$.

* In all other cases (e.g. one of $M$ and $M'$ is a variable and the other is an operator, or they are distinct operators), $M\sim_\rho M'$ is false.

It is easy to prove by induction that:

* For any $M\in Raw(V,s)$ we have $M\sim_{id} M$.
* If $M\sim_\rho M'$ then $M' \sim_{\rho^{-1}} M$.
* If $M\sim_\rho M'$ and $M' \sim_{\rho'} M''$, then $M\sim_{\rho'\circ\rho} M''$.

In particular, each $\sim_{id}$ is an equivalence relation on $Raw(V,s)$.

## Weakening, exchange, and contraction

For any function $\sigma :V\to W$, we define a function $Raw(V,s) \to Raw(W,s)$, written $M \mapsto M[\sigma]$, by induction on $M$.  When $\sigma$ is a subset inclusion, this is "weakening": adding a new unused free variable.  But to define weakening inductively, we will need to involve $M[\sigma]$ when $\sigma$ is an injection that is not a subset inclusion, and it is no extra trouble to define it for any function $\sigma$ at all.

* If $M=x\in V$, we define $x[\sigma] = \sigma(x)$.

* If $M=\mathtt{C}(X;\vec{M})$, we would like to define $M[\sigma]$ to be "$\mathtt{C}(X;\vec{N})$" where $N_j = M_j[\sigma]$.  But this is not allowed by our definitions, since $X$ may not be disjoint from $W$ (though it is disjoint from $V$).  Thus, recall that we have the successive freshening $X^{[W]}$ that is disjoint from $W$ and an order-preserving bijection $\xi :X \cong X^{[W]}$.  Let $\xi_j:X_j \cong X^{[W]}_j$ be the restriction of $\xi$ to the variables bound in argument $j$; then recursively we have $M_j[\sigma\cup \xi_j] \in Raw(W\cup X^{[W]}_j,s_j)$.  If we write $N_j = M_j[\sigma\cup \xi_j]$, then we can define $\mathtt{C}(X;\vec{M})[\sigma] = \mathtt{C}(X^{[W]};\vec{N})$.

It is easy to prove by induction that if $\rho,\rho'$ are bijections and $\rho' \circ \sigma = \sigma'\circ \rho$, then $M\sim_\rho M'$ implies $M[\sigma] \sim_{\rho'} M'[\sigma']$.  That is, the structural rules respect $\alpha$-equivalence.

## Substitution

Let $N\in Raw(V,tm)$ and $M\in Raw(V\cup \{x\},s)$ where $x\notin V$; we want to define $M[N/x] \in Raw(V,s)$ by induction on $M$.

* If $M=x$, then $x[N/x] = N$; this is well-typed since in this case $s=tm$.

* If $M=y$ for some variable $y\in V$, then $y[N/x] = y$.

* If $M = \mathtt{C}(X;\vec{M})$, we want to recursively substitute $N$ for $x$ in each $M_j$.  But recall that $M_j \in Raw(V\cup \{x\} \cup X_j,s_j)$, so in order to write "$M_j[N_j/x]$" we need $N_j \in Raw(V\cup X_j,tm)$, whereas we are given only $N\in Raw(V,tm)$.  Thus, we define $N_j = N[\sigma_j]$, where $\sigma_j:V\to V\cup X_j$ is the obvious inclusion.  Then we can define $P_j = M_j[N[\sigma_j]/x]$ and hence $M[N/x] = \mathtt{C}(X;\vec{P})$.

Note that [[substitution]] is automatically "capture-avoiding" because of our "strong scoping" and local Barendregt convention.  Before we can write $M[N/x]$, strong scoping requires $M$ and $N$ to have the same free variables (except for $x$, which only $M$ has), and no bound variables in $M$ can coincide with these free variables; thus no free variables in $N$ can get "captured" when it is substituted under binders in $M$.  If $M$ and $N$ are not "given" with the same free variables, we need to explicitly weaken them first in order to substitute, and the definition of weakening was forced by strong scoping to rename all bound variables to keep them distinct from the newly added free ones; in particular, the bound variables in $M$ must get renamed to differ from any free variables in $N$.  Finally, the definition of substitution is also forced by strong scoping to rename *bound* variables in $N$ (using the weakening $[\sigma_j]$) to keep them distinct from any bound variables in $M$ under which they are substituted, ensuring that $M[N/x]$ still satisfies the Barendregt convention.

category: Initiality Project


Initiality Project - Raw Syntax - Pi-types

operator | sort | vars | type args | term args | scoping              | sugared syntax
---------|------|------|-----------|-----------|----------------------|--------------------
$\Pi$    | $ty$ | $x$  | $A$, $B$  |           | $B\lhd x$            | $\Pi(x:A).B$
$\lambda$| $tm$ | $x$  | $A$, $B$  | $M$       | $B\lhd x$, $M\lhd x$ | $\lambda(x:A.B).M$
$App$    | $tm$ | $x$  | $A$, $B$  | $M$, $N$  | $B\lhd x$            | $App^{(x:A).B}(M,N)$


Initiality Project - References

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

A

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#awodey_2018_natural-models-of-homotopy-type-theory} [[Steve Awodey]], _Natural models of homotopy type theory_

: Math. Structures Comput. Sci. 28 (2018), no. 2, 241--286.

    [arXiv:1406.3219](https://arxiv.org/abs/1406.3219), [doi:10.1017/S0960129516000268](https://doi.org/10.1017/S0960129516000268), [MR](https://mathscinet.ams.org/mathscinet-getitem?mr=3742564), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#awodey_2018_natural-models-of-homotopy-type-theory)

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

K

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#kapulkin_2012_the-simplicial-model-of-univalent-foundations} [[Krzysztof Kapulkin]] and [[Peter LeFanu Lumsdaine]], _The simplicial model of univalent foundations (after Voevodsky)_

: 2012, Revised 2018 as v5

    [arXiv:1211.2851](https://arxiv.org/abs/1211.2851), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#kapulkin_2012_the-simplicial-model-of-univalent-foundations)

    Conjecture 1.2.9 in the article says,

    > Let $\mathbf{T}$ be the type theory given by the structural rules of Section A.1, plus any combination of the logical rules of Sections A.2, A.3. Then $\mathcal{C}(\mathbf{T})$ is initial among contextual categories with the correspondingly-named extra structure.

    The next paragraph of the article says,

    > In other words, if $\mathcal{C}$ is a contextual category with structure corresponding to the logical rules of a type theory $\mathbf{T}$, then there should be a unique homomorphism $\mathcal{C}(\mathbf{T}) \to \mathcal{C}$ interpreting the syntax of $\mathbf{T}$ in $\mathcal{C}$.  As discussed at the beginning of this section, the Correctness Theorem of [Str91, Ch. III, p. 181] gives an analogous fact for a rather smaller type theory, while the status of the present conjecture is debated, accepted by some but not all in the ﬁeld as a straightforward extension of that theorem.

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

S

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#streicher_1991_semantics-of-type-theory} [[Thomas Streicher]], _Semantics of type theory_, Correctness, completeness and independence results

: With a foreword by Martin Wirsing, Progress in Theoretical Computer Science, Birkhäuser Boston, Inc., Boston, MA, 1991, xii+298 pp., ISBN: 0-8176-3594-7

    [doi:10.1007/978-1-4612-0433-6](https://doi.org/10.1007/978-1-4612-0433-6), [MR](https://mathscinet.ams.org/mathscinet-getitem?mr=1134134), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#streicher_1991_semantics-of-type-theory)

    This book was suggested by Mike Shulman, in an [nForum message](https://nforum.ncatlab.org/discussion/8904/a-communal-proof-of-an-initiality-theorem/?Focus=71137#Comment_71137), as a primary reference for the [[Initiality Project]].

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

V

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2015_hott-is-not_an-interpretation-of-mltt-into-abstract-homotopy-theory} [[Vladimir Voevodsky]], _HoTT is not an interpretation of MLTT into abstract homotopy theory_

: Article at the `homotopytypetheory.org` blog, January 11, 2015

    [URL](https://homotopytypetheory.org/2015/01/11/hott-is-not-an-interpretation-of-mltt-into-abstract-homotopy-theory/), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#voevodsky_2015_hott-is-not_an-interpretation-of-mltt-into-abstract-homotopy-theory)

    There is a discussion of the initiality conjecture in the last four paragraphs of the article.

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2015_from-syntax-to-semantics-of-dependent-type-theories} [[Vladimir Voevodsky]], _From syntax to semantics of dependent type theories --- formalized_

: Slides of a lecture at RDP 2015, Warsaw, June 30, 2015

    [URL](https://www.math.ias.edu/vladimir/sites/math.ias.edu.vladimir/files/2015_06_30_RDP.pdf), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#voevodsky_2015_from-syntax-to-semantics-of-dependent-type-theories)

    There is a statement of the initiality conjecture on slide 18.  Slide 19 has some remarks on the difficulty of the conjecture, and slide 20 has some remarks on the importance of the conjecture.

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2016_mathematical-theory-of-type-theories} [[Vladimir Voevodsky]], _Mathematical theory of type theories and the initiality conjecture_

: Research proposal to the Templeton Foundation, 2016

    [URL](https://www.math.ias.edu/Voevodsky/voevodsky-publications_abstracts.html#TempletonProposal), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#voevodsky_2016_mathematical-theory-of-type-theories)

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2017_the-meta-theory-of-dependent-type-theories} [[Vladimir Voevodsky]], _The meta-theory of dependent type theories_

: Video, Members Seminar, Institute for Advanced Study, Princeton, NJ, USA, February 27, 2017

    [URL](https://video.ias.edu/membsem/2017/0227-VladimirVoevodsky), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#voevodsky_2017_the-meta-theory-of-dependent-type-theories)

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

{#voevodsky_2017_models-interpretations-and-the-initiality-conjectures} [[Vladimir Voevodsky]], _Models, interpretations and the initiality conjectures_

: Lecture at the special session on category theory and type theory in honor of Per Martin-Löf on his 75th birthday, August 17--19, 2017, during the Logic Colloquium 2017, August 14--20, 2017, Stockholm

    [URL](https://www.math.ias.edu/Voevodsky/voevodsky-publications_abstracts.html#logcoll-1), [BibTeX](/nlab/show/Initiality+Project+-+BibTeX+database#voevodsky_2017_models-interpretations-and-the-initiality-conjectures)

    The annotation at the URL of the document says, "This is a clear and enlightening sketch of Voevodsky's entire program!".

[//]: # (SEPARATOR COMMENT ──────────────────────────────────────────)

## See also ##

* [[Initiality Project]]
* [[Initiality Project - BibTeX database]]

category: Initiality Project


Initiality Project - Semantics

# Initiality Project - Semantics

This page is part of the [[Initiality Project]].

* table of contents
{:toc}

## Idea

See [[categorical model of dependent types]], for now.

## Basic definitions

+--{: .un_defn}
###### Definition
A (natural-model-style) **category with families** (abbreviated **CwF**) consists of:

* a (small) [[category]] $C$
* a [[terminal object]] $1\in C$
* two [[presheaves]] $Tm,Ty \in [C^{op},Set]$
* a morphism $of:Tm \to Ty$
* An *algebraic representation* for the map $of$, i.e. a function assigning to each morphism $A:y \Gamma \to Ty$, where $\Gamma\in C$ and $y$ denotes the [[Yoneda embedding]], an object $\Gamma.A\in C$ and a [[pullback square]]
$$\array{ y(\Gamma.A) & \to & Tm \\ \downarrow &&\downarrow \\ y\Gamma & \xrightarrow{A} & Ty. } $$
=--

Note that an algebraic representation for $of$ can be equivalently expressed as choice of a right adjoint $\mathsf{ext}$ for the corresponding functor of [[category of elements|categories of elements]] $el(Tm) \to el(Ty)$.

We consider categories with families as set-level structures (in particular, as [[strict categories]]), with morphism between them that preserve all the structure "on the nose" rather than merely up to isomorphism.

+--{: .un_defn}
###### Definition
Let $C$ and $D$ be CwFs.  A **CwF morphism** is a functor $F:C\to D$, preserving the specified terminal objects (on the nose), together with a commutative square in $[C^{op},Set]$:
$$\array{ Tm_C & \to & F^*(Tm_D) \\ \downarrow & & \downarrow \\ Ty_C & \to & F^*(Ty_D) }$$
such that, for all $\Gamma \in C$, and $A : y\Gamma \to Ty_C$, the square
$$
\array{
y(F(\Gamma.A)) & \to & Tm_D \\
\downarrow & & \downarrow \\
y(F(\Gamma)) & \to & Ty_D
}
$$
is equal (on the nose) to the chosen pullback square corresponding to the morphism $y(F(\Gamma)) \to Ty_D$.
=--

The last condition can be reformulated in terms of categories of elements by requiring that the square of categories and functors
$$
\array{
el(Ty_C) & \to & el(Ty_D) \\
\downarrow & & \downarrow \\
el(Tm_C) & \to & el(Tm_D)
}
$$
commutes strictly, where the vertical maps are the $\mathsf{ext}$ functors corresponding to the chosen algebraic representations and the horizontal maps are $\el (F_*)$ the category of elements functor composed with the direct image functor applied to $F$.

This defines a category $\mathbf{CwF}$ of categories with families and their morphisms, in which we aim to construct an initial object.

## Type structure

Each type forming operation corresponds to structure on a CwF that can be expressed naturally in terms of categorical operations in the presheaf category $[C^{op},Set]$.

### $\Pi$-types

[[!include Initiality Project - Semantics - Pi-types]]

category: Initiality Project


Initiality Project - Semantics - Pi-types

Given a presheaf $T$ on a CwF $C$, let $T^\Pi(\Gamma) = \Sigma_{A \in Ty(\Gamma)}T(\Gamma . A)$, so that $Ty^\Pi$ is the presheaf consisting of pairs of a type $A$ and a type $B$ in a context extended by $A$ and $Tm^\Pi$ is the presheaf of pairs of a type $A$ and a term in a context extended by $A$.

+--{: .un_defn}
######Definition
Let $C$ be a CwF. A **$\Pi$-type** structure on $C$ consists of :

* a natural transformation $\Pi : Ty^\Pi \to Ty$
* a natural transformation $\lambda : Tm^\Pi \to Tm$
* and a natural isomorphism
$$\langle -, -\rangle : [C^{op}, Set]( -, Ty^\Pi) \times [C^{op}, Set](-, Tm) \to [C^{op}, Set](-, Tm^\Pi)$$
exhibiting the following square as a pullback-square
$$
\array{
Tm^\Pi & \xrightarrow{\lambda} & Tm \\
of^\Pi \downarrow & & \downarrow of \\
Ty^\Pi & \xrightarrow{\Pi} & Ty
}
$$
=--


Initiality Project - Substitution

# Initiality Project - Substitution

This page is part of the [[Initiality Project]].

* table of contents
{:toc}

## Statements

Based on the definition of the [[Initiality Project - Partial Interpretation|partial interpretation functions]], we now prove the following substitution properties by mutual induction over raw terms and types.

### Weakening, exchange, and contraction

Let $V_1,V_2 \subseteq Var$ be finite, and suppose $\theta : V_1\to V_2$ is a function.  Then:

* For any raw type $A$, the composite partial morphism $Tm^{V_2} \xrightarrow{Tm^\theta} Tm^{V_1} \overset{\llbracket A \rrbracket^{V_1}_{type}}\rightharpoonup Ty$ is contained in the partial morphism  $Tm^{V_2} \overset{\llbracket A[\theta] \rrbracket^{V_2}_{type}}\rightharpoonup Ty$.
* For any raw term $T$, the composite partial morphism $Tm^{V_2} \xrightarrow{Tm^\theta} Tm^{V_1} \overset{\llbracket T \rrbracket^{V_1}_{\Rightarrow}}\rightharpoonup Tm$ is contained in the partial morphism  $Tm^{V_2} \overset{\llbracket T[\theta] \rrbracket^{V_2}_{\Rightarrow}}\rightharpoonup Tm$.
* For any raw term $T$, the composite partial morphism $Tm^{V_2}\times Ty \xrightarrow{Tm^\theta} Tm^{V_1} \times Ty \overset{\llbracket T \rrbracket^{V_1}_{\Leftarrow}}\rightharpoonup Tm$ is contained in the partial morphism  $Tm^{V_2}\times Ty \overset{\llbracket T[\theta] \rrbracket^{V_2}_{\Leftarrow}}\rightharpoonup Tm$.

Here $A[\theta]$ and $T[\theta]$ denote simultaneous capture-avoiding substitution of $\theta(x)$ for each variable $x\in V_1$.  When $\theta$ is a bijection, this asserts invariance under renaming of free variables.  When $\theta$ is an inclusion, it asserts weakening, and when $\theta$ is surjective it is contraction.  Note that in general these containments can be strict, e.g. if some variable in $V_2 \setminus \theta(V_1)$ appears freely in $A$ or $T$, then the composites may have empty domain while the morphisms they are being compared to might not.

### Substitution

Let $V\subseteq Var$ be finite and $x\in Var\setminus V$, while $N$ is a raw term.  Then:

* For any raw type $A$, the composite partial morphism $Tm^V \overset{(id,\llbracket N \rrbracket^V_{\Rightarrow})}{\rightharpoonup} Tm^{V\cup \{x\}} \overset{\llbracket A \rrbracket^{V\cup \{x\}}_{type}}{\rightharpoonup} Ty$ is contained in the partial morphism $Tm^V \overset{\llbracket A[N/x] \rrbracket^V_{type}}{\rightharpoonup} Ty$.
* For any raw term $T$, the composite partial morphism $Tm^V \overset{(id,\llbracket N \rrbracket^V_{\Rightarrow})}{\rightharpoonup} Tm^{V\cup \{x\}} \overset{\llbracket T \rrbracket^{V\cup \{x\}}_{\Rightarrow}}{\rightharpoonup} Tm$ is contained in the partial morphism $Tm^V \overset{\llbracket T[N/x] \rrbracket^V_{\Rightarrow}}{\rightharpoonup} Tm$.
* For any raw term $T$, the composite partial morphism $Tm^V\times Ty \overset{(id,\llbracket N \rrbracket^V_{\Rightarrow},id)}{\rightharpoonup} Tm^{V\cup \{x\}}\times Ty \overset{\llbracket T \rrbracket^{V\cup \{x\}}_{\Leftarrow}}{\rightharpoonup} Tm$ is contained in the partial morphism $Tm^V \times Ty\overset{\llbracket T[N/x] \rrbracket^V_{\Leftarrow}}{\rightharpoonup} Tm$.

## Inductive clauses

TODO.


Initiality Project - Term Model

# Initiality Project - The Term Model

This page is part of the [[Initiality Project]].

* table of contents
{: toc}

## Base Theory

We define a [[Initiality Project - Semantics|category with families]] as follows:

* Its objects are the [[Initiality Project - Type Theory|valid contexts]].  (Do we need to mod out by judgmental equality here?)
* Its types in context $\Gamma$ are the $A$ such that $\Gamma \vdash A\,type$ is derivable, modulo derivable judgmental equalities $\Gamma \vdash A\equiv B \, type$.
* Its terms of type $A$ in context $\Gamma$ are the $T$ such that $\Gamma \vdash T \Leftarrow A$ is derivable, modulo derivable judgmental equalities $\Gamma \vdash S \equiv T : A$.

TODO: prove that this defines a category with families.

## Type formers

### $\Pi$-types

[[!include Initiality Project - Term Model - Pi-types]]

category: Initiality Project


Initiality Project - Term Model - Pi-types

TODO: Prove that the term model category with families has $\Pi$-type structure.


Initiality Project - Totality

# Initiality Project - Totality

This page is part of the [[Initiality Project]].

* table of contents
{: toc}

## Overview

We now prove that the [[Initiality Project - Partial Interpretation|partial interpretations]] of types, terms, and contexts satisfy the following "local" totality properties, for any raw context $\Gamma$ with variables $V$.

1. If $\Gamma \vdash A\, type$ is derivable, then the domain of $\llbracket A \rrbracket^V_{type} : Tm^V \rightharpoonup Ty$ contains $\llbracket\Gamma\rrbracket$.
1. If $\Gamma \vdash T \Rightarrow A$ is derivable, then the domain of $\llbracket T \rrbracket^V_{\Rightarrow} : Tm^V \rightharpoonup Tm$ contains $\llbracket\Gamma\rrbracket$, and the composite $Tm^V \overset{\llbracket T \rrbracket^V_{\Rightarrow}}{\rightharpoonup} Tm \to Ty$ agrees with $\llbracket A \rrbracket^V_{type}$ on $\llbracket\Gamma\rrbracket$.
1. If $\Gamma \vdash T \Leftarrow A$ is derivable, then the domain of $\llbracket T \rrbracket^V_{\Leftarrow} : Tm^V \times Ty \rightharpoonup Tm$ contains the subobject defined by $\llbracket\Gamma\rrbracket \hookrightarrow Tm^V \overset{(id,\llbracket A \rrbracket^V_{type})}{\rightharpoonup} Tm^V \times Ty$.
1. If $\Gamma \vdash A \equiv B \, type$ is derivable, then $\llbracket A \rrbracket^V_{type}$ and $\llbracket B \rrbracket^V_{type}$ agree when their domains are intersected with each other and also with $\llbracket\Gamma\rrbracket$.
1. If $\Gamma \vdash S \equiv T : A$ is derivable, then $\llbracket S \rrbracket^V_{\Leftarrow}$ and $\llbracket T \rrbracket^V_{\Leftarrow}$ agree when their domains are intersected with each other and also with the subobject $\llbracket\Gamma\rrbracket \hookrightarrow Tm^V \times Ty$ defined in (3) above.

The proof is by mutual induction on these mutually defined inductive judgments; thus we have one clause for each primitive rule in our [[Initiality Project - Type Theory|type theory]].

## Inductive clauses

### Variables

### Mode-switching

### Equality

### Constants

### $\Pi$-types

include [[Initiality Project - Totality - Pi-types]]

## Valid Contexts

The above totality theorem is called "local" because it only says the interpretations are defined on the interpretation of the context; if the context is invalid then the latter interpretation could be empty.  However, with the local totality theorem in hand, we can deduce a *global* totality theorem for valid contexts.  Note that this parallels how the notion of valid context was defined after giving the inductive definition of the judgments, and also how the partial interpretation of contexts was defined after giving the partial interpretations of types and terms.

The global totality theorem is:

+-- {: .un_theorem}
###### Theorem
If $\Gamma$ is a valid context, then $\llbracket \Gamma \rrbracket$ is a [[representable presheaf]].
=--
+-- {: .proof}
###### Proof
By induction on the length of $\Gamma$.  If it is empty, then $\llbracket () \rrbracket = 1$, the terminal presheaf, which is representable as our CwF $C$ has a terminal object.

For a context extension $(\Gamma,x:A)$, by induction we have $\llbracket \Gamma \rrbracket$ representable.  [[Initiality Project - Partial Interpretation|Recall]] that $\llbracket\Gamma,x:A\rrbracket$ is defined as a pullback
$$ \array { \llbracket \Gamma, x:A \rrbracket & \to & Tm \\ \downarrow & & \downarrow \\ U & \to & Ty. }$$
Since $Tm\to Ty$ is, by our definition of CwF, a [[representable morphism]], it will therefore suffice to show that $U$ is a representable object.

Now $U$ is by definition the intersection of $\llbracket\Gamma\rrbracket$ with the domain of $\llbracket A \rrbracket^V_{type}$.  But since $(\Gamma,x:A)$ is valid, $\Gamma \vdash A \, type$ is derivable, so by the local totality theorem, the domain of $\llbracket A \rrbracket^V_{type}$ *contains* $\llbracket \Gamma \rrbracket$.  Thus, $U = \llbracket \Gamma \rrbracket$, which is representable by the inductive hypothesis.
=--

Furthermore, since $Tm\to Ty$ is *algebraically* represented, at each step we obtain a specified representing object for $\llbracket\Gamma\rrbracket$.  We henceforth abusively denote this object of $C$ also by $\llbracket\Gamma\rrbracket$.

Combining this with the local totality theorem, we can extract more traditional-looking interpretations of derivable judgments with valid contexts that are "purely inside $C$" rather than phrased in terms of presheaves.

* If $\Gamma$ is valid and $\Gamma \vdash A\,type$ is derivable, we have (by local totality) a total morphism $\llbracket \Gamma \rrbracket \xrightarrow{\llbracket A \rrbracket^V_{type}} Ty$, hence (by the Yoneda lemma) an element of the set $Ty(\llbracket \Gamma\rrbracket)$, which we may denote $\llbracket A \rrbracket^\Gamma_{type}$.
* If $\Gamma$ is valid and $\Gamma \vdash T \Rightarrow A$ is derivable, we have a total morphism $\llbracket \Gamma \rrbracket \xrightarrow{\llbracket A \rrbracket^V_{\Rightarrow}} Tm$, hence an element of the set $Tm(\llbracket \Gamma\rrbracket)$ which we may denote $\llbracket T \rrbracket^\Gamma_{\Rightarrow}$.  By the rest of the local totality theorem for type synthesis, the underlying semantic type of this semantic term is $\llbracket A \rrbracket^\Gamma_{type}$.
* If $\Gamma$ is valid and $\Gamma \vdash T \Leftarrow A$ is derivable, we similarly obtain an element $\llbracket T \rrbracket^\Gamma_{\Leftarrow A}$ of $Tm(\llbracket \Gamma\rrbracket)$, whose underlying semantic type is $\llbracket A \rrbracket^\Gamma_{type}$.

category: Initiality Project


Initiality Project - Type Theory

# Initiality Project - Type Theory

This page is part of the [[Initiality Project]].

* table of contents
{: toc}

## Bidirectionality

All our terms are fully annotated.  For instance, we write $App^{(x:A)B}(M,N)$ rather than just $App(M,N)$.  It is, at best, unclear whether any less than fully annotated syntax can be used in an initiality theorem without "preprocessing" that is tantamount to annotating it.

In particular, this means that given $\Gamma$ and $T$, if $\Gamma \vdash T:A$ can be derived for any value of $A$, then there is a canonical such $A$ that can be deduced syntactically, or *synthesized*, from $\Gamma$ and $T$. For instance, if $App^{(x:A)B}(M,N)$ has any type, then it must have the type $B[N/x]$. On the other hand, the conversion rule

$$\frac{\Gamma \vdash T:A \qquad \Gamma \vdash A\equiv B \,type}{\Gamma \vdash T:B} $$

implies that $App^{(x:A)B}(M,N)$ must also have any type that is judgmentally *equal* to $B[N/x]$.  But although it *has* these types, there is a sense in which it "has" them in a different sense from the one unique one that it synthesizes.  Moreover, the conversion rule is perhaps the ickiest thing to deal with in an initiality theorem, because it can be applied absolutely anywhere, over and over again, leading to many many different derivations of the same judgment that should not be distinguished semantically.

Note that since all our terms are fully annotated, all of our formation, introduction, and elimination rules can synthesize their types.  However, the type annotations also tell us what types the subterms need to have (i.e. the types that must occur in the premises of the corresponding rule), in order for the term to have its canonical type.  These types may not be *syntactically* equal to the types synthesized by the subterms, so we need to *check* subterms against the types we want. The check should succeed if and only if the subterm's synthesized type is *judgmentally* equal to the one we want; and this is the only place that the conversion rule really *needs* to be applied. So in the $App^{(x:A)B}(M,N)$ example, it *synthesizes* only $B[N/x]$, up to syntactic equality, but it *checks against* any type judgmentally equal to $B[N/x]$.

Type theorists have a standard technique for distinguishing these two situations and controlling the use of the conversion rule, known as [[bidirectional typechecking]].  Instead of one judgment $\Gamma\vdash T:A$, we have two typing judgments:

* $\Gamma \vdash T \Rightarrow A$: in context $\Gamma$ the term $T$ *synthesizes* the type $A$.  Here $A$ is, if it exists, uniquely determined by $\Gamma$ and $T$: it is an "output" to their "inputs".
* $\Gamma \vdash T \Leftarrow A$: in context $\Gamma$ the term $T$ *checks against* the type $A$.  Here $\Gamma$, $T$, and $A$ are all "inputs" and the only "output" is the truth value of whether the typecheck is valid.

Whereas unidirectional typing rules have the conversion rule, allowing the type to be changed at any point to a judgmentally equal one, with bidirectional typing rules, conversion is only used when switching from a synthesizing premise to a checking conclusion, using the "mode-switching" rule:

$$\frac{\Gamma \vdash T\Rightarrow A \qquad \Gamma \vdash A\equiv B \,type}{\Gamma \vdash T\Leftarrow B} $$

Unlike typical versions of bidirectional typing, in our approach the checking judgment is defined *solely* by the mode-switching rule, and all other typing rules conclude a synthesizing judgment. This variant doesn't help with typechecking algorithms, but it still factors out type conversion cleanly: the equality judgment is used when, and only when, the mode switches.

So in summary, terms formers are fully annotated, their typing rules *synthesize* a type in the conclusion, and have premises that *check* their subterms against appropriate types.  So the mode-switching rule gets applied a lot, because it's the only way, in our system, to derive a checking judgment.

From a syntactic perspective, there are many advantages of bidirectional typechecking, but it is unclear at present whether any of them are relevant to categorical semantics (although by using a bidirectional framework we are better placed to take advantage of them if they do become relevant).  But more importantly, the natural structure of the semantic interpretation, as suggested by [[Peter Lumsdaine]], matches the syntactic bidirectional picture quite closely, and it may be clarifying to make that analogy more precise.

Typical versions of bidirectional typing also have bidirectional *equality* rules, which essentially implement an algorithm for equality-checking.  (Such partially-type-directed algorithms have advantages over simply normalizing both terms and comparing normal forms, such as more easily incorporating eta-conversion.)  However, since we want our theorem to generalize to type theories in which equality is not algorithmic (e.g. theories with equality reflection) --- and more importantly, since in semantic equality there is no "output information" to ever compute --- we will not orient our equality judgments.

Our sort of bidirectional theory is very closely related to a unidirectional theory that may be more familiar to some readers.  Roughly speaking, to go from a unidirectional theory to our sort of bidirectional one: make sure everything is fully annotated, make the conclusions of formation/introduction/elimination rules synthesizing and their premises checking, and replace the conversion rule by the mode-switching rule.  Oppositely, to recover a unidirectional theory from our bidirectional one, simply collapse both checking and synthesizing judgments into the "term has a type" judgment $T:A$, thereby generalizing the mode-switching rule to the conversion rule.  Below we will make this "isomorphism" a bit more precise.

## Contexts

A **raw context** is a finite list of pairs consisting of a variable and a raw term in which the variables occurring are all pairwise distinct.  Each such pair, written $x:A$, is called a **typing declaration**, with $A$ being a type to which the variable $x$ belongs.

A **valid context** is a raw context $(x_1:A_1, \dots ,x_n:A_n)$ such that each judgment $x_1:A_1,\dots, x_k:A_k \vdash A_{k+1} \, type$ is derivable by the rules below.  This notion is defined *a posteriori* after the primitive rules for all the judgments have been given.  In particular, the judgments themselves never refer to context validity.  The intuitive interpretation of a judgment-in-context $\Gamma\vdash \mathcal{J}$ should therefore be "*if* $\Gamma$ is a valid context, then $\mathcal{J}$ holds in that context" (and this is the meaning we will give it semantically).

## Judgment forms {#judgements}

Our type theory has five judgment forms.  Here $\Gamma$ is a metavariable ranging over raw contexts, while $S,T,A,B$ are metavariables ranging over raw terms.

1. $\Gamma \vdash A\,type$ --- "$A$ is a type in context $\Gamma$".
2. $\Gamma \vdash T \Leftarrow A$ --- "$T$ can be checked to have type $A$ in context $\Gamma$"
3. $\Gamma \vdash T \Rightarrow A$ --- "$T$ synthesizes the type $A$ in context $\Gamma$"
4. $\Gamma \vdash A \equiv B \, type$ --- "$A$ and $B$ are judgmentally equal types in context $\Gamma$"
5. $\Gamma \vdash S \equiv T : A$ --- "$S$ and $T$ are judgmentally equal terms of type $A$ in context $\Gamma$"

### Modes, preconditions, etc.

All the metavariables occurring in all of our judgments should be regarded as "inputs", with the sole exception that $A$ in the synthesizing judgment $\Gamma \vdash T \Rightarrow A$ is an output.  In other words, if we regard "searching for a derivation of some judgment" as an "algorithm", with the rules for deriving that judgment as the "cases to try" and their premises as the resulting "recursive calls", then in all but one case the algorithm takes all the arguments of the judgment as inputs and returns only a [[truth value]], while in the exceptional case $\Gamma \vdash T \Rightarrow A$ it takes $\Gamma$ and $T$ as inputs and returns $A$ as output (if it succeeds, otherwise it returns failure).

Note, though, that because our judgmental equality is not bidirectional and need not be even semidecidable, these "algorithms" are not really algorithms, unless we regard the equality judgment as a sort of "oracle" that they can invoke.

Similarly, we regard validity of all the "inputs" of each judgment as something that the "caller" should ensure, while validity of the "output" as something that the function returning it should "promise".  For example, the rules for deriving a judgment such as $\Gamma \vdash T \Leftarrow A$ need only be "correct" under the *assumption* that $\Gamma$ is a valid context and $\Gamma \vdash A\,type$, but in turn these assumptions must ensure that all the analogous "preconditions" of all *premises* of such rules hold.

## Primitive rules

### Structural rules

The main structural rule is the "variable" or "hypothesis" rule, which says that if a variable is declared in a context, then as a term it synthesizes the type that it is declared with:

$$ \frac{(x:A) \in \Gamma}{\Gamma \vdash x \Rightarrow A}$$

The other structural rules of weakening, contraction, and substitution will be admissible.

### Mode-switching rule

The mode-switching rule says that to check that a term has a given type, we first synthesize a type for that term and then check that this type equals the given one.  In our fully annotated system, this is the *only* way to derive the checking judgment $\Gamma \vdash T \Leftarrow B$.

$$ \frac{\Gamma \vdash T \Rightarrow A \qquad \Gamma \vdash A \equiv B \, type}{\Gamma \vdash T \Leftarrow B}$$

This is also the only incarnation of the conversion rule, which in a "unidirectional" system is

$$ \frac{\Gamma \vdash T : A \qquad \Gamma \vdash A \equiv B \, type}{\Gamma \vdash T : B.}$$

A bidirectional system controls this rule more carefully, enforcing it to be used (when and) only when the mode switches.

### Equality rules

We have primitive rules asserting that equality of terms and types are both reflexive, transitive, and symmetric, and moreover that equality of terms is invariant under equality of types.

For equality of types $\Gamma \vdash A \equiv B$, we take as input that $\Gamma \vdash A\,type$ and $\Gamma \vdash B\,type$, so we don't need any premise in the reflexivity rule, but we do need one in the transitivity rule.

[[!include Initiality Project - Type Theory - Type equality]]

Similarly $\Gamma \vdash T \equiv S : A$ takes as input that $\Gamma \vdash T \Leftarrow A$ and $\Gamma \vdash S \Leftarrow A$. It also takes $\Gamma \vdash A type$.

[[!include Initiality Project - Type Theory - Term equality]]

### Constant rules

TODO.  In fact, specifying the constant rules is part of the "signature".

### Type former rules

Each type former ($\Pi$-types, $\Sigma$-types, etc.) has a collection of rules giving its

* formation rule (when is it a valid type)
* introduction rule (what terms synthesize this type)
* elimination rule (how terms in this type can be used)
* equality rules ([[beta-reduction]] and, sometimes, [[eta-conversion]])
* congruence rules (the type former and its introduction and elimination forms respect judgmental equality)

### $\Pi$-types

[[!include Initiality Project - Type Theory - Pi-types]]

## Valid Contexts and Telescopes

A (raw) **telescope** $\Delta $ is a (raw) context. A **valid telescope** $\Gamma \vdash \Delta ok$ is defined by another inductively-defined judgment form:

$$\frac{}{\Gamma \vdash \cdot ok}$$
$$\,$$
$$\frac{\Gamma \vdash \Delta ok \qquad
        \Gamma,\Delta \vdash A type \qquad
        x \notin \Gamma,\Delta}
    {\Gamma \vdash \Delta,x:A ok}$$

Intuitively, a telescope is an open context. So a **valid context** can now be formalized as the closed special case of a valid telescope, with the single-rule judgment form:

$$\frac{\cdot \vdash \Gamma ok}{\Gamma ok}$$

A valid telescope can also be understood as a valid multi-step context extension. So we have the theorem:

($\Gamma ok$ and $\Gamma \vdash \Delta ok$) if and only if $\Gamma,\Delta ok$.

You can also concatenate telescopes:

($\Gamma \vdash \Delta ok$ and $\Gamma,\Delta \vdash \Delta' ok$) if and only if $\Gamma \vdash \Delta,\Delta' ok$.

In fact, by the definition of context validity, the multi-step context extension is a special case of telescope concatenation.

## Bidirectional vs Unidirectional

As noted above, there is a canonical correspondence between our bidirectional theory (with any choice of type formers) and a unidirectional one obtained by collapsing both typing judgments $T\Leftarrow A$ and $T\Rightarrow A$ into one $T:A$ (and thereby the mode-switching rule into the conversion rule).

In fact, we can prove that $\Gamma \vdash T\Leftarrow A$ is derivable bidirectionally if and only if $\Gamma \vdash T: A$ is derivable unidirectionally.

The "only if" direction is easy: just change all the $\Leftarrow$s and $\Rightarrow$s to colons in a bidirectional rule to obtain a unidirectional one.  For "if", it suffices to show that all the unidirectional rules translate to *admissible* bidirectional rules under $(T:A)\mapsto(T\Leftarrow A)$.  Each type-former rule in fact translates to a derivable rule: follow the corresponding bidirectional rule (whose conclusion is synthesizing) by the mode-switching rule applied to reflexivity.  The only thing requiring a bit of thought is the conversion rule: we want to show that

$$ \frac{\Gamma \vdash T\Leftarrow A \qquad \Gamma \vdash A\equiv B \, type}{\Gamma \vdash T\Leftarrow B}$$

is admissible in our bidirectional theory.  But as noted above, any derivation of $\Gamma \vdash T\Leftarrow A$ must end with an invocation of the mode-switching rule.  So there must be some $C$, such that $\Gamma \vdash T\Leftarrow A$ was derived by

$$ \frac{\Gamma \vdash T\Rightarrow C \qquad \Gamma \vdash C\equiv A \, type}{\Gamma \vdash T\Leftarrow A.}$$

So the premises of that rule instance must be derivable.  Thus, we can combine the derivations of $\Gamma \vdash C\equiv A \, type$ and $\Gamma \vdash A\equiv B \, type$ with transitivity, then apply the mode-switching rule

$$ \frac{\Gamma \vdash T\Rightarrow C \qquad \Gamma \vdash C\equiv B \, type}{\Gamma \vdash T\Leftarrow B}$$

to get a derivation of $\Gamma \vdash T\Leftarrow B$ as desired.

## Admissible rules

### Inversion lemmas

Inversion lemmas let you "take apart" a derivation by observing that only certain rule(s) could've been used as the last step of the derivation, based on the form of one or more objects being judged.

TODO

### Structural rules

Writing $\Gamma \vdash \mathcal{J}$ for one of the [judgments](#judgements), the following rules are admissible by mutual induction on derivations :
$$ \frac{\Gamma \vdash \Gamma' \qquad \Gamma, \Gamma' \vdash \mathcal{J}}{\Gamma, x:A, \Gamma' \vdash \mathcal{J}} $$
$$\,$$
$$ \frac{\Gamma \vdash B\,type \qquad \Gamma, x:A, y:B, \Gamma' \vdash \mathcal{J}}{\Gamma, y:B, x:A, \Gamma' \vdash \mathcal{J}} $$
$$\,$$
$$ \frac{\Gamma, x:A, y:A, \Gamma' \vdash \mathcal{J}}{\Gamma, x:A, \Gamma'[x/y] \vdash \mathcal{J}[x/y]} $$
$$\,$$
$$ \frac{\Gamma \vdash T \Rightarrow A \qquad \Gamma, x:A, \Gamma' \vdash \mathcal{J}}{\Gamma, \Gamma'[T/x] \vdash \mathcal{J}[T/x]} $$

(TODO)

### Sanity check

Sanity checks are theorems about the formal judgments that provide some confidence that the rules are propagating validity presuppositions correctly. Since we have only one judgment form that establishes any of its presuppositions, there seems to be only one sanity check we can do:

If $\Gamma ok$ and $\Gamma \vdash M \Rightarrow A$ then $\Gamma \vdash A type$.

Intuitively, a derivation $\Gamma \vdash M \Rightarrow A$ somehow contains a derivation of the presupposition $\Gamma \vdash A type$, but the derivation only makes sense when the other presupposition, $\Gamma ok$, of this judgment form, has been independently established. For example, the variable rule intuitively punts the derivation of type validity to the independent derivation of context validity.

The proof is by induction on the main derivation—of $\Gamma \vdash M \Rightarrow A$—and makes use of the admissible substitution rule:

TODO

category: Initiality Project


Initiality Project - Type Theory - Pi-types

$$
\begin{gathered}
\frac{\Gamma \vdash A \, type \qquad \Gamma, x:A \vdash B\,type}{\Gamma \vdash \Pi(x:A) .B \, type}
\\
\\
\frac{\Gamma \vdash A \, type \qquad \Gamma, x:A \vdash B\,type \qquad \Gamma \vdash M \Leftarrow \Pi(x:A). B \qquad \Gamma \vdash N \Leftarrow A}{\Gamma \vdash App^{x:A.B}(M,N) \Rightarrow B[N/x]}
\\
\\
\frac{\Gamma \vdash A \, type \qquad \Gamma,x:A \vdash B \,type \qquad \Gamma,x:A \vdash M \Leftarrow B}{\Gamma \vdash \lambda(x:A.B).M \Rightarrow \Pi(x:A). B}
\\
\\
\frac{\Gamma\vdash A \equiv A' \, type \qquad \Gamma, x:A \vdash B \equiv B' \, type}{\Gamma \vdash App^{x:A.B}(\lambda(x:A'.B').M,N) \equiv M[N/x] : B[N/x]}
\\
\\
\frac{\Gamma, y:A \vdash App^{x:A.B}(M,y) \equiv App^{x:A.B}(M',y) : B[y/x]}{\Gamma \vdash M \equiv M' : \Pi(x:A).B }
\\
\\
\frac{\Gamma \vdash A \equiv A' type \qquad \Gamma, x:A \vdash B \equiv B' type}{\Gamma \vdash \Pi(x:A)B \equiv \Pi(x:A')B' type}
\\
\\
\frac{
   \Gamma \vdash A \equiv A' type \qquad
   \Gamma, x:A \vdash B \equiv B' type \qquad
   \Gamma, x:A \vdash M \equiv M' : B
}
{\Gamma \vdash \lambda(x:A.B).M \equiv \lambda(x:A'.B').M' : \Pi(x:A).B}
\\
\\
\frac{
   \Gamma \vdash A \equiv A' type \qquad
   \Gamma, x:A \vdash B \equiv B' type \qquad
   \Gamma \vdash M \equiv M' : \Pi(x:A)B \qquad
   \Gamma \vdash N \equiv N' : A
}
{\Gamma \vdash App^{x:A.B}(M, N) \equiv App^{x:A'.B'}(M', N') : B[N/x]}
\end{gathered}
$$


Initiality Project - Type Theory - Term equality

$$\frac{ }{\Gamma \vdash T \equiv T : A}$$

$$\,$$

$$\frac{\Gamma \vdash T \equiv S : A}{\Gamma \vdash S \equiv T : A}$$

$$\,$$

$$\frac{\Gamma \vdash S \Leftarrow A \qquad \Gamma \vdash T \equiv S : A\qquad \Gamma \vdash S \equiv R : A}{\Gamma \vdash T \equiv R : A}$$

$$\,$$

$$\frac{\Gamma \vdash A\,type \qquad \Gamma \vdash T \equiv S : A \qquad \Gamma \vdash A \equiv B type}{\Gamma \vdash T \equiv S : B}$$


Initiality Project - Type Theory - Type equality

$$\frac{}{\Gamma \vdash A \equiv A type}$$
$$\,$$
$$\frac{\Gamma \vdash A \equiv B type}{\Gamma \vdash B \equiv A type}$$
$$\,$$
$$\frac{\Gamma \vdash B\,type\qquad \Gamma\vdash A \equiv B type \qquad \Gamma\vdash B \equiv C type}{\Gamma \vdash A \equiv C type}$$


Initiality Project - Uniqueness

# Initiality Project - Uniqueness

This page is part of the [[Initiality Project]].

* table of contents
{: toc}

## Overview

I suspect that the easiest way to prove uniqueness will be to use the [[initial object]] lemma: if $I$ is an object of a category $D$ equipped with a natural transformation $\iota$ from the [[constant functor]] $\Delta I$ at $I$ to the [[identity functor]] $Id_D$ such that the component $\iota_I : I\to I$ is the identity morphism, then $I$ is an initial object.

This means we have two things to prove: that the [[Initiality Project - Functor|interpretation functor]]s are natural, and that the interpretation functor into the [[Initiality Project - Term Model|term model]] itself is the identity.  I believe that both should be provable by induction over *raw* syntax with reference only to the [[Initiality Project - Partial Interpretation|partial interpretation functions]], since we have separately [[Initiality Project - Totality|proved]] that these partial functions happen to be total.

## Naturality

TODO

## The tautological interpretation

TODO

category: Initiality Project


Inj

+-- {: .rightHandSide}
+-- {: .toc .clickDown tabindex="0"}
### Context
#### Category theory
+-- {: .hide}
[[!include category theory - contents]]
=--
=--
=--

* table of contents
{: toc}

## Idea
 {#Idea}

__$Inj$__ (or __$Set_inj$__) is the [[wide subcategory]] of the [[topos]] [[Set]] with its [[morphisms]] restricted to [[monomorphisms]] ([[injective functions]]).

*  The [[arrow category]] $Inj^\to$ of $Inj$ is, in turn, a [[wide subcategory]] of the [quasitopos](quasitopos#mono) [[M-category#mono|Mono]] of set monomorphisms.  The two categories have the same objects, namely injective functions, but in [[Mono]] the morphism are arbitrary commutative squares from one injection to another, whereas in $Inj^\to$ the other two arrows in the commutative square must also be injective.  Note that $Mono$ is a [[reflective subcategory]] of the [[category of presheaves|presheaf topos]] $Set^{\to}$ (the [[Sierpinski topos]]), and the category of [[separated presheaves]] for the [[double negation#topology|double negation topology]] on $Set^\to$.

* For a set $S$, its [[power set]] ($\mathcal{P}S$ or $2^S$) is the [[slice category]] $Inj/S$ which has  objects that are injections to $S$ and morphisms that are injections of injections that form commuting triangles.  $2^S$ is a
quasitopos because it is a  [[Heyting algebra]].

## Related concepts

* [[Surj]]
* [[FinInj]]