News for hackers. Stuff that matters.
Re:λ Calculus [pdf] by andsoitis on Thursday August 17, 2023 @09:41PM (#37170559)
created by Church and Kleene in the 1930’s!

Even more beautiful than the y combinator

Re:λ Calculus [pdf] by curryhoward on Thursday August 17, 2023 @10:19PM (#37170762)
> Even more beautiful than the y combinator

That's a bit of a strange statement. The Y combinator is an expression in λ calculus. It's like saying French is even more beautiful than the phrase "nouveau départ".

Re:λ Calculus [pdf] by cbarrick on Thursday August 17, 2023 @10:19PM (#37170760)
They're one and the same.

    Y = λf.(λx.f (x x)) (λx.f (x x))
Re:λ Calculus [pdf] by curryhoward on Thursday August 17, 2023 @10:22PM (#37170778)
The Y combinator is not the same as λ calculus. The Y combinator is an expression in λ calculus.
Re:λ Calculus [pdf] by lmm on Thursday August 17, 2023 @10:34PM (#37170841)
The Y combinator is in a sense the heart of the λ calculus; it's a key discovery for understanding that the λ calculus is universal, which is what makes it a useful concept rather than an arbitrary bundle of rules.
Re:λ Calculus [pdf] by andsoitis on Thursday August 17, 2023 @10:43PM (#37170887)
> heart of the λ calculus

The Y combinator is a specific fixed-point combinator in lambda calculus. It is used to express recursion in lambda calculus where direct recursion is not initially available due to the lack of named functions. The Y combinator demonstrates the power of lambda calculus.

Re:λ Calculus [pdf] by downvotetruth on Friday August 18, 2023 @12:28AM (#37171407)
Yet fails to show the full power of the strict side.
Re:λ Calculus [pdf] by Hirrolot on Thursday August 17, 2023 @10:58PM (#37170964)
> which is what makes it a useful concept rather than an arbitrary bundle of rules.

I cannot recall a single practical FP language based on the Y combinator for recursion. The typical approach is to extend lambda calculus with a separate recursion primitive.

Re:λ Calculus [pdf] by lmm on Thursday August 17, 2023 @11:19PM (#37171082)
The lambda calculus was never meant to be a "practical FP language"; it predates programming languages and even mechanical stored-program computers as we understand them.
Re:λ Calculus [pdf] by Hirrolot on Thursday August 17, 2023 @11:31PM (#37171138)
What are the useful cases of the Y combinator then? (I don't say that the lambda calculus is useless, I was responding to a comment that claimed the lambda calculus is useless without the Y combinator.)
Re:λ Calculus [pdf] by lmm on Friday August 18, 2023 @12:00AM (#37171259)
Emulating recursion, and more generally the whole Church-Turing thesis. The fact that you can represent mechanical computation through, well, computation - the fact that equating those concepts makes sense at all, which was such a huge innovation that today it seems too banal to even notice.
Re:λ Calculus [pdf] by Hirrolot on Friday August 18, 2023 @12:36AM (#37171446)
You keep answering with the same words though. My question was _where_ the Y combinator is useful, not _what_ it is designed for, which I am of course aware of.
Re:λ Calculus [pdf] by lmm on Friday August 18, 2023 @02:39AM (#37172052)
What do you mean "where"? In Princeton? In the Proceedings of the London Mathematical Society? In the head of anyone who presumes to think about computation?
Re:λ Calculus [pdf] by kragen on Friday August 18, 2023 @12:30AM (#37171410)
the great benefit of the y-combinator is that it permits indefinite iteration in a system that seems at first glance to not support iteration

so when you're faced with a formal system that doesn't seem to support iteration, perhaps because you are trying to design it to guarantee termination, a useful exercise is to try to construct an analogue of the y-combinator in it

if you can't, you may have gained enough insight into the problem to show that the system actually does guarantee termination, and maybe even show useful time bounds on it

if you can, you have usually shown the system is turing-complete, which means you can appeal to rice's theorem whenever you are tempted to analyze the behavior of the system in any way, so you can satisfy yourself with partial decision procedures that work often enough to be useful and are conservative in the appropriate way, rather than wasting time trying to find a complete solution

(also if you're designing the system you might consider either supporting iteration more directly or removing the back door)

every once in a while it's also useful in practice to be able to program a weird machine, too

Re:λ Calculus [pdf] by Hirrolot on Friday August 18, 2023 @12:47AM (#37171484)
> the great benefit of the y-combinator is that it permits indefinite iteration in a system that seems at first glance to not support iteration at all

This is only the case for untyped systems. If we try to type the Y combinator, we will eventually need some notion of recursion. For example, in Haskell/OCaml we can type it with iso/equi-recursive types. How many truly untyped systems we use in practice?

The Y combinator as a counterexample of termination is a great insight though!

Re:λ Calculus [pdf] by kragen on Friday August 18, 2023 @01:03AM (#37171540)
typing is often an excellent way to ensure termination
Re:λ Calculus [pdf] by fanf2 on Friday August 18, 2023 @02:06AM (#37171847)
Dynamically typed programming languages are statically untyped.

You might argue they are unityped, but that’s really a type theoretician’s job security: if a language has the untyped lambda calculus as a subset (like the python example in this discussion) it’s reasonable to call it untyped.

Re:λ Calculus [pdf] by agumonkey on Friday August 18, 2023 @07:22AM (#37174178)
you could argue that Y is also an advanced CPS transform and a lot of patterns rely on similar idea, mainly passing the following computation as a functional parameter
Re:λ Calculus [pdf] by fanf2 on Friday August 18, 2023 @01:57AM (#37171798)
The Miranda programming language was an early lazy functional programming language, an ancestor of Haskell. It compiles down to combinators, and uses combinator reduction as its evaluation strategy. This became obsolete by the end of the 1980s but it’s still neat to learn how it works. One of the primitive combinators is Y. Here is its implementation: https://github.com/pkreyenhop/miranda/blob/master/reduce.c#L...
Re:λ Calculus [pdf] by cvoss on Thursday August 17, 2023 @11:00PM (#37170975)
The simply typed, and, especialy, the dependently typed lambda calculi are extremely versatile and powerful subsets of untyped lambda calculus which do not admit the Y combinator. Their usefulness does not at all require universality, and are, perhaps, more useful for being typed.
Re:λ Calculus [pdf] by lmm on Thursday August 17, 2023 @11:17PM (#37171074)
There are many useful things that are not "the lambda calculus". "The lambda calculus" is more widely known and important, largely because it is universal, hence Church-Turing thesis.
Re:λ Calculus [pdf] by cvoss on Thursday August 17, 2023 @11:44PM (#37171192)
Of course there are other useful things. But a comment argued that the presence of Y is what makes untyped lambda calculus useful. My rebuttal is that certain subsets which (intentionally) lack Y are more useful. Applications of typed calculi abound, but one rarely sees applications of the untyped calculus. Universality is not so important, it would seem. For example, infinite computations can still be modeled in typed calculi, but one has more control over them in that setting than running on "bare metal" untyped lambda calculus.
Re:λ Calculus [pdf] by lmm on Thursday August 17, 2023 @11:53PM (#37171230)
Ok, "useless" is a slight exaggeration; non-universal calculi can be useful. But the thing that makes the lambda calculus so important and famous - the thing that makes it "the lambda calculus - is universality, and that's the ur-application that makes all of the subsequent application of calculi to mechanical computation possible.