Earlier quoted context omitted.
Could you write this in Java?
I think it is approximately `public T y(Function f)`.
Could you use your Java code to define Factorial?
21–30 of 39 posts
Earlier quoted context omitted.
It's perfectly well typed in System F as "forall a. (a -> a) -> a".
Could you write this in Java?
Earlier quoted context omitted.
"if you are allowed to name things at all, getting the function to refer to itself is pretty straightforward" The neat thing about the Y-combinator is that it allows recursion to be defined in systems, such as the lambda calculus, which don't have naming and therefore a function can't refer to itself by name.
Well, lambda calculus does have names, but yes, I agree, it's a very neat trick in environments where naming is heavily restricted, it gives you "anonymous recursion", so to speak. Church-encoding is another similarly neat trick, for environments with substitutions/applications but without built-in natural numbers. It's just that it seems there are not that many such systems used in practice except for "advanced type…
I agree that it's rarely justifiable to actually run a translated version of this code, but sometimes it gives you an easy proof of non-termination for some kind of formal system, which often gives you an easy proof of undecidability, which can save you a lot of time trying to figure out how to compute the uncomputable. Or it may persuade you that adding some feature to your design is a bad idea because it eliminates termination guarantees.
Curiously, the graphical lambda calculus notation for the Y combinator slightly resembles a Y, especially when bent a little as shown at the top of https://tromp.github.io/cl/diagrams.html
Earlier quoted context omitted.
It's perfectly well typed in System F as "forall a. (a -> a) -> a".
Can you type that in System F? It doesn't seem logically valid, a -> a is trivially true, but apparently implies any a?
(Haskell)
anyType :: a
anyType = anyType
or(Rust)
fn any_type() -> T {
any_type()
}Earlier quoted context omitted.
Well, lambda calculus does have names, but yes, I agree, it's a very neat trick in environments where naming is heavily restricted, it gives you "anonymous recursion", so to speak. Church-encoding is another similarly neat trick, for environments with substitutions/applications but without built-in natural numbers. It's just that it seems there are not that many such systems used in practice except for "advanced type…
The applicative-order Y-combinator that Mike derives at the end, λf.(λx.f λy.x x y)(λx.f λy.x x y), can be straightforwardly compiled into SKI-combinators, which don't have naming at all. I agree that it's rarely justifiable to actually run a translated version of this code, but sometimes it gives you an easy proof of non-termination for some kind of formal system, which often gives you an easy proof of undecidabilit…
Earlier quoted context omitted.
It's perfectly well typed in System F as "forall a. (a -> a) -> a".
Could you write this in Java?
If you prefer video, here is an explanation of the Y combinator from Gerald Sussman himself: https://www.youtube.com/watch?v=0m6hoOelZH8#t=1h12m30s