Zulip Chat Archive

Stream: new members

Topic: What do we call (name : type)?


Eric Wieser (Jun 16 2021 at 16:38):

What's the name for this syntax, eg (1 : ℤ)? It's not a coercion in this case. Is it a "type ascription"? A "type annotation"? Something else? Or is there no agreed upon name?

Floris van Doorn (Jun 16 2021 at 17:26):

Type ascription is a common term for it.

Scott Morrison (Jun 17 2021 at 05:14):

It would also be fair in some cases to call it an "explicit coercion" if the purpose of the type ascription is to trigger a coercion.

Julian Berman (Jun 17 2021 at 08:24):

Relatedly, I can't find where this syntax is actually defined (in Lean 4), so if anyone knows where that lives, would love to see it. I've looked in the usual places I think (src/Lean/Parser/, src/Init/Notation*.lean)

Kevin Buzzard (Jun 17 2021 at 08:25):

Are you talking about numerals explicitly or about e.g. (a : Y) when a : X and X = Y? These are two different things, right?

Eric Wieser (Jun 17 2021 at 08:32):

I think I'm talking about the X = Y case, but there X is really full of metavariables so it seems wrong to equate it to Y

Mario Carneiro (Jun 17 2021 at 09:23):

Julian Berman said:

Relatedly, I can't find where this syntax is actually defined (in Lean 4), so if anyone knows where that lives, would love to see it. I've looked in the usual places I think (src/Lean/Parser/, src/Init/Notation*.lean)

https://github.com/leanprover/lean4/blob/master/src/Lean/Parser/Term.lean#L67

Mario Carneiro (Jun 17 2021 at 09:23):

def typeAscription := leading_parser " : " >> termParser

Mario Carneiro (Jun 17 2021 at 09:23):

which should also answer eric's question

Mario Carneiro (Jun 17 2021 at 09:26):

The primary effect of a type ascription is to assert that a term has a type; this has the side effect of unifying metavariables and inserting coercions where necessary, so you will usually see it in those contexts, but you can also use it when it has no effect, just to make something clear to the reader.


Last updated: Dec 20 2023 at 11:08 UTC