Injective types

3 views
Skip to first unread message

escardo...@gmail.com

unread,
Apr 30, 2019, 7:05:52 PM4/30/19
to Homotopy Type Theory
I would like to advertise this paper, which investigates injective types and algebraically injective types, and their relationship (https://arxiv.org/abs/1903.01211).

In this paper, it is important to take universe levels seriously (for the reasons explained there). In the HoTT book, and in Coq, the universes are taken to be cumulative on the nose, and we pretend, notationally, that there is only one universe (this is called typical ambiguity). Based on the experience of this paper, I have the feeling that the loss of cumulativity, as in Agda, but also as in the infty-topos model of univalent type theory by Mike (https://arxiv.org/abs/1904.07004) is a good thing. In particular, I am not sure how typical ambiguity with cumulativity would be able to handle what is said in the above injectives paper.

When I say "would be able to handle" I don't mean just "accepting the constructions", but also present them to the (mathematical) user in such a way that is both understandable and usable as a blackbox (by quoting published resuls).

Martin

Michael Shulman

unread,
Apr 30, 2019, 10:51:07 PM4/30/19
to Martin Hotzel Escardo, Homotopy Type Theory
Interesting point! I definitely agree that we don't want to be
*forced* to be typically ambiguous; there are times when we need to
explicitly distinguish universes. This was already the case in a few
places in the book, e.g. Lemmas 10.3.21 and 10.3.22. And Coq's
universe polymorphism now also *allows* the user to explicitly specify
universe levels when desired. (On the other hand, it's also nice to
not be forced to label all universes explicitly all the time. But on
the third hard, at least in Coq as it is now, the interaction of
user-specified universes with automatically-deduced ones seems to be
fairly fragile.)

However, it's not clear to me why cumulativity would be a problem. In
fact you wrote in the paper that "We don't assume that the universes
are cumulative... but we also don't assume that they are not". Which
makes it sound as though cumulativity, though not necessary, wouldn't
be a problem if it did hold -- would it?
> --
> You received this message because you are subscribed to the Google Groups "Homotopy Type Theory" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to HomotopyTypeThe...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

escardo...@gmail.com

unread,
May 1, 2019, 2:25:31 AM5/1/19
to Homotopy Type Theory
On 01/05/2019 03:50, Michael Shulman wrote:> Interesting point!  I definitely agree that we don't want to be
> *forced* to be typically ambiguous; there are times when we need to
> explicitly distinguish universes.  This was already the case in a few
> places in the book, e.g. Lemmas 10.3.21 and 10.3.22.  And Coq's
> universe polymorphism now also *allows* the user to explicitly specify
> universe levels when desired.  (On the other hand, it's also nice to
> not be forced to label all universes explicitly all the time.  But on
> the third hard, at least in Coq as it is now, the interaction of
> user-specified universes with automatically-deduced ones seems to be
> fairly fragile.)
Right.

> However, it's not clear to me why cumulativity would be a problem.
In Agda each type gets a unique universe (or at most one universe) and
often (but not always) the system is able to infer them if we write
question marks "?" for them (but not always).

Cumulativity is not "on the nose" in the sense that from X : U_l you
would get X : U_m for m ≥ l. Instead, if you need to have (a copy of)
X in U_m, you need to use an explicit embedding U_l → U_m. (I only
ever used this embedding to show that U_l is a retract of U_m if we
assume propositional resizing.)

In practice, however, I never needed to use this embedding, as the
closure properties for universes work with more than one universe at a
time. For instance,

  if X:U_l and A : X → U_m, then Π X A : U_{max l m}.

With this kind of closure property, I haven't encountered the
practical need for cumulativity.

It is nice, in practice, that universes are uniquely
determined. Insted of thousands of level constraints, we have a
unique, small, (polymorphic) level assignment.

> In fact you wrote in the paper that "We don't assume that the
> universes are cumulative... but we also don't assume that they are
> not".  Which makes it sound as though cumulativity, though not
> necessary, wouldn't be a problem if it did hold -- would it?
In theory it wouldn't be a problem if it holds. However, if Agda did
have cumulativity, it would lose the unique-level assignment property
that I use to infer the levels of the results from my given levels of
the data. However, in the absence of a concrete proof assistant with
the option to enable and disable cumulativity, it is impossible to
perform experiments to confirm or reject this conjectural impression.

I consider the universe-level system of Agda to be excellent in
practice, and easy to use. Moreover, as I said, if I publish a
mathematical theorem developed in Agda, I think it is fair to the
reader to let them know what the universe level assignments are rather
than just say that they exist. In some cases, as injectivity, the
universe levels are crucial, and if we ignore them we get false
claims.

Best,
Martin

Michael Shulman

unread,
May 1, 2019, 12:55:50 PM5/1/19
to Martin Hotzel Escardo, Homotopy Type Theory
On Tue, Apr 30, 2019 at 11:25 PM <escardo...@gmail.com> wrote:
> It is nice, in practice, that universes are uniquely
> determined. Insted of thousands of level constraints, we have a
> unique, small, (polymorphic) level assignment.
> ...
> I think it is fair to the
> reader to let them know what the universe level assignments are rather
> than just say that they exist. In some cases, as injectivity, the
> universe levels are crucial, and if we ignore them we get false
> claims.

Yes, this is a good point in favor of Agda-style non-cumulative
Russell universes over Coq-style cumulative Russell universes.

But isn't there a middle ground with Tarski universes? Suppose we
have explicit lifting operators Lift : U_i -> U_{i+1}, so that as in
Agda we have unique small polymorphic level assignments. But then
suppose we have *definitional* equalities El(Lift(A)) == El(A). Then
on the (rare) occasions when we do have to explicitly lift types from
one universe to another, we would get stronger cumulativity behavior.
(And I could imagine a proof assistant that implements this and sugars
away the El to look like Russell universes to the user.)

escardo...@gmail.com

unread,
May 2, 2019, 4:46:22 PM5/2/19
to Homotopy Type Theory


On Wednesday, 1 May 2019 17:55:50 UTC+1, Michael Shulman wrote

Yes, this is a good point in favor of Agda-style non-cumulative
Russell universes over Coq-style cumulative Russell universes.

But isn't there a middle ground with Tarski universes?  

It would be nice to have such a middle ground, particularly because formulating universe assumptions in each single definition and theorem is unfamiliar in mathematical practice, and so "typical ambiguity" (pretending there is only one universe) is potentially a good idea for many (or even most) examples. But not in the paper I advertised in this thread.

Here I post an example when Giraud did precisely that, namely to assume two arbitrary universes U and V, explaining why this is needed in that level of generality after the formulation of a theorem and its proof, given to me by Thierry Coquand:

  https://www.cs.bham.ac.uk/~mhe/giraud-universes.pdf (photo of one page of a book).
 
The book is “Cohmologie non abelienne” (1971, https://www.springer.com/gp/book/9783540053071).

Suppose we
have explicit lifting operators Lift : U_i -> U_{i+1}, so that as in
Agda we have unique small polymorphic level assignments.  But then
suppose we have *definitional* equalities El(Lift(A)) == El(A).  Then
on the (rare) occasions when we do have to explicitly lift types from
one universe to another,

I can confirm from a 26k line Agda development (with comments and repeated blank lines removed in this counting of the number of lines) that not once did I need to embed a universe into a larger universe, except when I wanted to state the theorem that any universe is a retract of any larger universe if one assumes the propositional resizing axiom (any proposition in a universe U has an equivalent copy in any universe V). So I would say that such situations are *extremely rare* in practice.
 
we would get stronger cumulativity behavior.
(And I could imagine a proof assistant that implements this and sugars
away the El to look like Russell universes to the user.)
 
At the moment we can choose cumulativity (Coq) or non-cumulativity (Agda), and there is no system that combines the virtues of Coq and Agda regarding universe handling. (And I fear that such a system would potentially multiply the vices of both. :-) )

M.

Michael Shulman

unread,
May 3, 2019, 7:45:32 AM5/3/19
to Martin Hotzel Escardo, Homotopy Type Theory
I am more optimistic: I think there's a good chance we could do better
than both Coq and Agda. Of course sometimes when we try new things
they flop; but we can't make progress without trying new things.

For one thing, I don't think we should conflate typical ambiguity with
cumulativity. It just so happens that Coq has both and Agda has
neither, but in principle I see no reason they have to go together. I
see typical ambiguity as basically syntactic sugar or abuse of
notation, analogous to the use of implicit arguments: the reader or
proof assistant is tasked (if they feel like it) to go through and
insert level parameters as needed, accumulating constraints on these
parameters according to how the instance are used and thereby
"elaborating" a typically ambiguous development to a fully precise one
with (polymorphic) universe levels. Usually this will be possible,
but occasionally if the writer was careless there may be a universe
inconsistency.

It seems to me that this could be done in both a cumulative and a
non-cumulative system. True, in a non-cumulative system we get
different constraints, e.g. if we ever write "A=B" then it must be
that A and B live in the same universe, whereas in a cumulative system
we could be looser about such constraints. But your evidence (and
that of other universe-polymorphic users of Agda) suggests that such
constraints arising from non-cumulativity are not in practice a
problem. In fact, the unique assignment of levels in a non-cumulative
system suggests that the universe inference algorithm in a
hypothetical typically-ambiguous non-cumulative proof assistant would
probably be *simpler*, and less error-prone, than that of Coq. So I
don't see any argument here against typical ambiguity, as long as
there is the *option* to be unambiguous when necessary (which again,
even Coq now supports).

In particular, note that when a development is formalized in a
typically ambiguous proof assistant, it's not necessary for the
universe levels to be written in the source code, or even thought
about by the author, in order for the interested reader -- or even the
author themselves! -- to learn about what the universe constraints
are. They only have to compile the code, in particular running it
through the universe checker/elaborator, and then inspect the
resulting universe levels/constraints. I've done this in present-day
Coq myself, although the proliferation of universe parameters makes
the output hard to undertsand; I expect it would only be easier in a
hypothetical typically-ambiguous non-cumulative proof assistant. So
it seems to me that it should be possible to be "fair to the reader",
as you say, and still retain (some of) the advantages of typical
ambiguity.

I also think there's a good chance we can retain some cumulativity
without losing the benefits of non-cumulativity, by using a
Tarski-style lifting coercion as I sketched in my last email. (Isn't
this in the literature somewhere? I didn't think I'd made it up.) I
agree that it's rare to need this, but neither is it unheard-of; so if
we can make it more convenient to use with no drawback, why not? (Of
course, cumulativity is also trickier to model semantically, but
probably possible.)

Kenji Maillard

unread,
May 3, 2019, 9:24:38 AM5/3/19
to HomotopyT...@googlegroups.com
I think the paper "A calculus of constructions with explicit subtyping"
by Ali Assaf that can be found at https://hal.inria.fr/hal-01097401 is
a relevant reference for coercive lifts between Tarski style universes.

K.

Thierry Coquand

unread,
May 3, 2019, 2:23:50 PM5/3/19
to Kenji Maillard, HomotopyT...@googlegroups.com

Nils Anders Danielsson

unread,
May 7, 2019, 8:42:05 AM5/7/19
to Homotopy Type Theory
On 02/05/2019 22.46, escardo...@gmail.com wrote:
> I can confirm from a 26k line Agda development (with comments and
> repeated blank lines removed in this counting of the number of lines)
> that not once did I need to embed a universe into a larger universe,
> except when I wanted to state the theorem that any universe is a
> retract of any larger universe if one assumes the propositional
> resizing axiom (any proposition in a universe U has an equivalent copy
> in any universe V). So I would say that such situations are *extremely
> rare* in practice.

I once wrote some code where I made use of univalence at three different
levels. Does anyone know if one can prove that univalence at one level
implies univalence at lower levels, without making use of cumulativity?

--
/NAD

Andreas Nuyts

unread,
May 7, 2019, 9:51:48 AM5/7/19
to Nils Anders Danielsson, Homotopy Type Theory
Even with cumulativity, that sounds suspicious, because cumulativity of
U in a bigger universe V does not obviously give you a map

(A B : U) -> Id V A B -> Id U A B.

The J-rule does not allow you to build this map.

Martín Hötzel Escardó

unread,
May 7, 2019, 6:06:20 PM5/7/19
to Homotopy Type Theory
On 07/05/2019 14:51, Andreas Nuyts wrote:
> Even with cumulativity, that sounds suspicious, because cumulativity of 
> U in a bigger universe V does not obviously give you a map
> (A B : U) -> Id V A B -> Id U A B.
> The J-rule does not allow you to build this map.

Indeed.

In the non-cumulative system, with V bigger than U, you have a map
f : U → V with f A ≃ A. For example, if C is any contractible type in
V, you can take f A := A × C.

If both U and V are univalent, then any map f : U → V with f A ≃ A is
an embedding for all A : U, meaning that the canonical map

  Id U A B → Id V (f A) (f B)
  
is equivalence (or equivalently that the fibers of f are propositions).
I checked this in Agda.

The reformulation of your statement above with an explicit inclusion
f : U → V, namely

 (A B : U) -> Id V (f A) (f B) -> Id U A B,

which amounts to the left-cancellability of f, is a consequence of f
being an embedding, and in general strictly weaker than f being an
embedding.

But I don't see how to prove even the left-cancellability of f without
assuming univalence in the smaller universe U.

Assuming that V is univalent, Id V (f A) (f B) gives f A ≃ f B, and
then composing with the equivalences A ≃ f A and f B ≃ B we get A ≃ B.
If U were univalent we would get Id U A B and hence f would be
left-cancellable. But, as I said, the univalence of U and V gives
more, namely that f is an embedding.

And if V is univalent and f is an embedding, then U is univalent, for
A ≃ B is equivalent to f A ≃ f B and hence to Id V (f A) (f B), and
hence to Id U A B, using the embedding property in the last step.

So if V is univalent, then the smaller universe U is univalent iff
every map f : U → V with f A ≃ A for all A : U is an embedding (iff
some given such map is an embedding).

Martin
Reply all
Reply to author
Forward
0 new messages