$$ Y : \mu T . (T \to T) \to T. $$$$ Y = (\lambda f : T \to T) \big( (\lambda x: \mu A . A \to T). f (x x) \big) \big( (\lambda x: \mu A . A \to T). f (x x) \big) : (T \to T) \to T$$
AndNote that the $\mu$ types appear in the typing of the inner terms. In type systems that interpret $\forall$ such as with parametric polymorphism parametric polymorphism (this may not be correct…$\lambda P$):
$$ Y : \forall T . (T \to T) \to \forall T . (T \to T). $$ or dependent types ($\lambda \omega$) $Y$ can get a type as well, but the important point of this is addressed later (see Lambda Cube for a discussion of these type systems).
Relating the type of the $Y$-combinator and Godel's claim
Recall the claim that:
The true source of the incompleteness, is to be found ... in the fact that the formation of ever higher types can be continued into the transfinite
In type theory, the formation of ever higher types would correspond to using a type constructor, i.e. in $\lambda^{\to}$ that would be '$\to$.' For example, given types $A$ and $B$, we form the type $A \to B$, written more obscurely as $\to(A, B)$. When dealing with types mathematically, especially when considering recursive types, it can be convenient to think of types as trees, as demonstrated by this figure from Pierce's book:
In this figure, the labels 1
and 2
are just labels to identify positions and arity, and Top
is some given base type (typically a type inhabited by a single element, like $\{\cdot\}$ or x = x
- that these types exist and are inhabited are some axioms of the system). The type on the right of the figure is in fact an infinite type, as is hinted by the ellipsis. In $\mu$ notation it would be written:
$$ \mu T . \mathrm{Top} \to T $$
This can be interpreted as an (extended) equation:
$$ T = \mathrm{Top} \to T = \mathrm{Top} \to (\mathrm{Top} \to T) = \mathrm{Top} \to (\mathrm{Top} \to (\mathrm{Top} \to T))$$
(Here we get the continued equation by substituting the definition of $T$ for $T$ over and over again.)
This same procedure of unfolding the type definition from $\mu$ can be repeated with the inner types of the $Y$-combinator, revealing that there is an infinite type. Recall the type of the parameter of the inner term of $Y$:
$$ \mu A . A \to T$$
This is nearly the same as the infinite type shown above, but instead of "extending to the right" it will "extend to the left."
Unfortunately, $\mu$ doesn't correspond so nicely to logic. In other type systems, in particular when we have parametric polymorphism or dependent types, we need to interpret the $\forall$ symbol. But this is where the infinite type is hidden in these systems. In the notes above, $\forall$ is interpreted as an (transfinite) product, while in other systems it is interpreted as a natural transformation (see Bartosz Milewski's discussion of natural transformations in Category Theory for Programmers). In either case, we get infinite types if there is an infinite number of types.
The idea here is that when we can interpret:
$$ \forall x \phi(x) = \phi(x_1) \land \phi(x_2) \land \phi(x_3) ... $$
Where $x_1, x_2$ is an enumeration of all members of the domain. Don't ask what if the members aren't enumerable?, it's not relevant.
To truly wrap up Godel's claim we would need to show that any such extension to infinite types would lead to a typing of $Y$ and hence a valid proof of the diagonalization lemma (which, taking Kunen's lead, we'll assume is sufficient to prove incompleteness). I'm not prepared to really make this claim without making some further assumptions on the formal system. I bet if we assume that the formation of terms is defined inductively (or co-inductively), and composition is found somewhere, then something could be shown.