Y Combo: \f. (\x.f (XX)) (\x.f (XX)), accepts a function, returns a higher order function
The y combination is used to generate anonymous recursive functions.
What is anonymous recursive function, consider the following C language recursive function
int sum (int n) { return n = = 0? 0:n + sum (n-1);}
This function calls itself recursively, calling itself the name of the function body, which is called Sum,sum internal with the name sum, recursive calls to their own
In lambda calculus, you can write a similar expression, sum = \x. x = = 0? 0:sum x
But for a lambda expression, he is anonymous, and Lambda refers to itself in the process of defining it, and even if it is C + +, the lambda expression is not true.
Auto sum = [] (int n) { return n = = 0? 0:n + sum (n-1);};
The lambda expression itself is anonymous, and we need to bypass this restriction.
One possible solution is to use a higher-order function to wrap the sum above with another function: It takes a function f and returns a function that accepts X, determines the recursive end point, or calls F to continue the recursion:
G = \f. \x. x = = 0? 0:f (x-1)
Written in C + + is like this
Auto G = [] (function<int (int) > F) { return [&] (int x) { return x = = 0?: 0:x + f (x-1); };};
Now we find that when there is a function f that makes g (f) = [] (int x) {return x = = 0? 0:x + f (x-1);} = f, this f is exactly what we need the anonymous recursive function sum
G (f) = f, familiar, remember the concept of fixed point, we need the anonymous recursive function sum is the fixed point of function g
To solve this fixed point sum, we can get an anonymous recursive function, how to solve the attached
The final result: sum = yg,y and g are known before, so that sum is a function with the signature int (int), which is an anonymous recursive function
Y-sub-group is also called fixed point combination, which can be used to solve all anonymous recursive functions.
Attached: sum = YG makes the proof of g (sum) = sum:
Proof: For any g,g (YG) = YG
Make w = \x. G (xx), x = WW//This order is really too TM, anyway, I didn't think
There is x = WW = (\x. G (xx)) W = g (WW) = g (x)
Also because YG = (\x g (XX)) (\x. G (xx)) = WW = X
So g (x) = X is g (YG) = YG
Certificate of Completion
Lambda calculus-A brief description of the role of Y-composite