2008 August 7th Thursday (八月 七日 木曜日)
2008-09-03 20:47
393 查看
ISZERO = λ n. n (λ x. FALSE) TRUE
TRUE = λ u. λ v. u
FALSE = λ u. λ v. v
0 = λ f. λ x. x
1 = λ f. λ x. f x
2 = λ f. λ x. f (f x)
3 = λ f. λ x. f (f (f x))
FACT = λ n. n (λ u. MULT n (FACT (PRED n))) 1
FACT = Y (λ g. λ n. n (λ u. MULT n (g (PRED n))) 1)
Y = λ f. ((λ x. f (x x)) (λ x. f (x x)))
ISZERO 0
0 (λ x. FALSE) TRUE
=>TRUE
1 (λ x. FALSE) TRUE
=>(λ x. FALSE) TRUE
Here, the "TRUE" and "FALSE" must be considered as Church object, that is to say, they is used to
compute. Let's take a look at the first "FACT". The "n (λ u. MULT n (FACT (PRED n))) 1" will be
expanded by the Church Number "n". If the "n" is "0", okey, the "(λ u. MULT n (FACT (PRED n)))"
replaced the parameter "f" and "1" replaced the parameter "x" (Note: 1 = λ f. λ x. f x ). So, the
"1" is returned directly. In the second "FACT", the technique is similiar, the "(g (PRED n))" make
a recursion to loop multiply next Church number. If the "n (λ u. MULT n (g (PRED n))) 1" expression
find the "n" is "0", the "1" is returned directly; otherwise, the "1" is applied into the
"(λ u. MULT n (g (PRED n)))" lamba expression, the "1" passed into is ignored, the result of "MULT n (g (PRED n))"
is returned.
TRUE = λ u. λ v. u
FALSE = λ u. λ v. v
0 = λ f. λ x. x
1 = λ f. λ x. f x
2 = λ f. λ x. f (f x)
3 = λ f. λ x. f (f (f x))
FACT = λ n. n (λ u. MULT n (FACT (PRED n))) 1
FACT = Y (λ g. λ n. n (λ u. MULT n (g (PRED n))) 1)
Y = λ f. ((λ x. f (x x)) (λ x. f (x x)))
ISZERO 0
0 (λ x. FALSE) TRUE
=>TRUE
1 (λ x. FALSE) TRUE
=>(λ x. FALSE) TRUE
Here, the "TRUE" and "FALSE" must be considered as Church object, that is to say, they is used to
compute. Let's take a look at the first "FACT". The "n (λ u. MULT n (FACT (PRED n))) 1" will be
expanded by the Church Number "n". If the "n" is "0", okey, the "(λ u. MULT n (FACT (PRED n)))"
replaced the parameter "f" and "1" replaced the parameter "x" (Note: 1 = λ f. λ x. f x ). So, the
"1" is returned directly. In the second "FACT", the technique is similiar, the "(g (PRED n))" make
a recursion to loop multiply next Church number. If the "n (λ u. MULT n (g (PRED n))) 1" expression
find the "n" is "0", the "1" is returned directly; otherwise, the "1" is applied into the
"(λ u. MULT n (g (PRED n)))" lamba expression, the "1" passed into is ignored, the result of "MULT n (g (PRED n))"
is returned.
相关文章推荐
- 2008 August 14th Thursday (八月 十四日 木曜日)
- 2008 August 28th Thursday (八月 二十八日 木曜日)
- 2008 August 21th Thursday (八月 二十一日 木曜日)
- August 16th Thursday (八月 十四日 木曜日)
- May 7th Thursday (五月 七日 木曜日)
- August 7th Tuesday (八月 七日 火曜日)
- August 30th Thursday (八月 三十日 木曜日)
- August 9th Thursday (八月 九日 木曜日)
- June 7th Thursday (六月 七日 木曜日)
- August 23th Thursday (八月 二十三日 木曜日)
- August 2nd Thursday (八月 二日 木曜日)
- 2008 May 7th Wednesday (五月 七日 水曜日)
- 2008 August 6th Wednesday (八月 六日 水曜日)
- 2008 August 29th Friday (八月 二十九日 金曜日)
- 2008 September 25th Thursday (九月 二十五日 木曜日)
- 2008 October 16th Thursday (十月 十六日 木曜日)
- 2008 October 30th Thursday (十月 三十日 木曜日)
- 2008 March 14th Thursday (三月 十四日 木曜日)
- 2008 April 3th Thursday (四月 三日 木曜日)
- 2008 May 8th Thursday (五月 八日 木曜日)