I must find a function G
which has a fixed point, and this fixed point must be the Y combinator.
Recall that YF = F(YF)
for all F
. I want a function G
such that GY = Y
.
How to write such a function in in Haskell?
Let
g w = \f -> f (w f)
Then, if
y f = f (y f)
we have
g y
-- definition of g
= \f -> f (y f)
-- property of y
= \f -> y f
-- eta-conversion
= y
Hence, y
is a fixed point of g
.
More than that: the set of fixed points of g
is precisely the set of fixed point combinators. This is because above we did not exploit the definition of y
, but merely the fact that it is a fixed point combinator.
Note that y
is also a fixed point of id
(anything is a fixed point of id
) and of const y
(as @DanielWagner writes in his answer).
对于所有值v
,函数const v
具有(唯一的,因此也是最小的)定点v
。
Daniel's answer is very good, but I'd like to add the other extreme. Everything is a fixed point of the identity function. Thus, take G to be
\x -> x
indeed:
GY = (\x -> x)Y = Y
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.