Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Y combinator: Some functions do not have fixed points

The Wikipedia article on the Y combinator provides the following JavaScript implementation of the Y combinator:

function Y(f) {
    return (
        (function (x) {
            return f(function (v) { return x(x)(v); }); })
        (function (x) {
            return f(function (v) { return x(x)(v); }); })
    );
}

The existence of a Y combinator in JavaScript should imply that every JavaScript function has a fixed point (since for every function g, Y(g) and g(Y(g)) should be equal).

However, it isn't hard to come up with functions without fixed points that violate Y(g) = g(Y(g)) (see here). Even certain functionals do not have fixed points (see here).

How does the proof that every function has a fixed point reconcile with the given counter-examples? Is JavaScript not an untyped lambda calculus in which the proof that Y(g) = g(Y(g)) applies?

like image 932
Randomblue Avatar asked Jun 14 '12 11:06

Randomblue


People also ask

Can a function have no fixed points?

Fixed point of a functionNot all functions have fixed points: for example, f(x) = x + 1, has no fixed points, since x is never equal to x + 1 for any real number.

When a function has a fixed point?

The point p is a fixed point of the function g(x) if g(p) = p. The point p is a root of the function f(x) if f(x) = 0. f(x) has a root at p iff g(x) = x - f(x) has a fixed point at p.

How do you find all fixed points?

One way to find fixed points is by drawing graphs. There is a standard way of attacking such a problem. Simply graph x and f(x) and notice how often the graphs cross.

Can you recursion in lambda calculus?

Recursive definitions can also be used to define minimalization. It turns out that every recursive definition in the lambda calculus can be ``solved'' by finding its fixed point.


2 Answers

As far as I understand Wikipedia article, it doesn't imply anywhere that "that every JavaScript function has a fixed point" and this example simply shows how to implement Y combinator for functions that have it by their specification.

And no, according to definitions in that article and an article on fixed point, JavaScript can't be an untyped lambda calculus, because it can formulate functions that obviously fail "have a fixed point" check, like function f(x){ return x + 1 } or x ^ 1 if you want to include non-numbers and thus fail "every function has at least one fixed point" check too.

like image 107
Oleg V. Volkov Avatar answered Sep 30 '22 03:09

Oleg V. Volkov


The problem with lambda expressions is that they cannot be interpreted as functions in a mathematical sense, i.e. mappings from one set to another.

The reason is the cardinality of the set of functions from a set A on itself is always larger than the cardinality of A, so not all functions from A to A can be an element of A. That is, there is a function f: A -> A for which the expression f(f) does not make sense.

This is like the "set of all sets not containing itself", which does not make sense logically.

JavaScript is not a model of the lambda calculus.

The problem with your example is that

(lambda x.g(x x)) (lambda x.g(x x))

should be equivalent to

g((lambda x.g(x x)) (lambda x.g(x x)))

but it is not in your JavaScript program where g is the indicator function of 0.

x x is always undefined. Hence the first line evaluates to g (undefined) = 0. The second line evaluates to g (g (undefined)) = g (0) = 1. This means that your JavaScript model of the lambda calculus is, in fact, not really a model.

Since for each non-empty set D there is a function from D to D without a fixed point, obviously there can be no model of the lambda calculus. I think it should be even possible to prove that there cannot be an implementation of the Y-combinator in any Turing-complete language.

like image 34
JohnB Avatar answered Sep 30 '22 04:09

JohnB