Fuss-free universe hierarchies › A new idea: Working your way down from the top › The theoretical foundation [01I2]
I am now going to describe a way to set up a coherent universe hierarchy so as to ensure a parsimonious interpretation. I would like to emphasise that the dream code above can be elaborated to a traditional coherent universe hierarchy with enough equations, and that my reformulation here is only aiming to make this easier.
In essence the main idea is to think about the image of the universe decoding maps el[i]: U[i] -> Type. In the generalised algebraic theory, we have required that these encoding maps be injective; an easily overlooked consequence of the injectivity is that the image of the decoding map is a derivable sort in the generalised/essentially algebraic doctrine.
From this observation, we might instead consider a reformulation where instead of axiomatising the type codes and decoding maps and lifting coercions at each level and all the equations they must satisfy, we might instead axiomatise the images of the decoding maps in Type. This corresponds syntactically to defining a smallness judgement on types, which has a particularly extrinsic feeling to it. In fact, we would define this judgment using a judgemental partial ordering of universe levels; one example rule is the following:
(The real generalised algebraic theory would have a sort of smallness-proofs, but this sort is axiomatised as a proposition. The fact that coherence/proof-irrelevance is baked into the theory fully justifies a notation in which the proofs are omitted.)
Now, we recover the codes and the level coercions in one fell swoop by means of the following simple rules:
\frac { \Gamma \vdash A\ \mathit {small}_i }{ \Gamma \vdash \lceil A\rceil _i : U_i } \quad \frac {\Gamma \vdash A:U_i}{ \Gamma \vdash \lfloor A\rfloor _i\ \mathit {type} } \quad \frac {\Gamma \vdash A:U_i}{\Gamma \vdash \lfloor A \rfloor _i\ \mathit {small}_i} \frac { \Gamma \vdash A\ \mathit {type} \quad \Gamma \vdash A\ \mathit {small}_i }{ \Gamma \vdash \big \lfloor \lceil A \rceil _i \big \rfloor _i \equiv A\ \mathit {type} } \quad \frac { \Gamma \vdash \lfloor A\rfloor _i \equiv \lfloor B\rfloor _i\ \mathit {type} }{ \Gamma \vdash A \equiv B : U_i }Now, supposing that the smallness and level inequality judgements have been filled out sufficiently, we can derive codes for connectives at the lower levels from the corresponding top-level type connectives. For example, consider the dependent function space:
\frac { \displaystyle \frac { \Gamma \vdash A: U_i }{\Gamma \vdash \lfloor A \rfloor _i\ \mathit {type}} \quad \frac { \Gamma ,x:\lfloor A\rfloor _i \vdash B[x]: U_i }{\Gamma , x: \lfloor A\rfloor _i\vdash \lfloor B[x] \rfloor _i\ \mathit {type}} \quad \frac { (\cdots ) }{ \Gamma \vdash (x:\lfloor A\rfloor _i)\to \lfloor B[x]\rfloor _i \ \mathit {small}_i } }{ \Gamma \vdash \big \lceil (x:\lfloor A\rfloor _i)\to \lfloor B[x]\rfloor _i \big \rceil _i : U_i }Of course, the notation is a little noisy, but these operations are precisely the sorts of things that are easy for a bidirectional elaborator to insert (and then hide from the user). It works equally well for Agda-style hierarchies with joins:
\frac { \displaystyle \frac { \Gamma \vdash A: U_i }{\Gamma \vdash \lfloor A \rfloor _i\ \mathit {type}} \quad \frac { \Gamma ,x:\lfloor A\rfloor _i \vdash B[x]: U_j }{\Gamma , x: \lfloor A\rfloor _i\vdash \lfloor B[x] \rfloor _j\ \mathit {type}} \quad \frac { (\cdots ) }{ \Gamma \vdash (x:\lfloor A\rfloor _i)\to \lfloor B[x]\rfloor _j\ \mathit {small}_{i \sqcup j} } }{ \Gamma \vdash \big \lceil (x:\lfloor A\rfloor _i)\to \lfloor B[x]\rfloor _j \big \rceil _{i \sqcup j} : U_{i \sqcup j} }The beauty of this simple approach is that we cut by two-thirds the number of universe-related operations we must implement in the core language. In that sense, we have an equivalent reformulation of coherent universe hierarchies that is more friendly on the engineering side.