This problem is coming from Exercise 3.3 in Bacon's A Philosophical Introduction to Higher-order Logics. I am trying to do my due-diligence here and not skip problems, but this one stuck out to me.
Exercise 3.3 Argue that the variables appearing in Y((λY.(λx.Yx))Z) cannot be assigned types that make it into a well-typed term.
The chapter endnotes include a hint to argue that Z has to be the same type as Y. I think I understand why if Z is the same type as Y, that the term is not well-typed: If Z and Y are of the same type (τ→σ) then the formula includes an instance of self-application (Y: τ→σ and (λY.(λx.Yx))Z : τ→σ), forbidden by STLC.
What I'm looking for help with is what exactly makes it the case that Z and Y are of the same type? Any hints or discussion would be greatly appreciated. Also, am I right about what makes it the case that if Z and Y are the same type, then the term is not well-typed? Thanks all!