问题
I'm trying to understand the basics of lambda calculus and Church numerals. I have been doing a lot of reading and practising, but I seem to keep getting stuck with trying to see how some functions work.
The example I am stuck on is as follows. Perhaps someone can explain where I have gone wrong.
The Church numeral for 1 can be represented as:
λf. λx. f x
The exponentiation function on Church numerals (mn) can be given as:
λm. λn. n m
All I want to do is show that by applying the exponentiation function to 1 and 1, I get back 1, since 11 = 1. I am doing this, so I understand better how these functions work. My working is as follows and I get stuck every time:
// Exp (1 1)
(λm. λn. n m) (λf1. λx1. f1 x1) (λf2. λx2. f2 x2)
// Substitute for m
(λn. n (λf1. λx1. f1 x1)) (λf2. λx2. f2 x2)
// Substitute for n
(λf2. λx2. f2 x2) (λf1. λx1. f1 x1)
// Substitute for f2
(λx2. (λf1. λx1. f1 x1) x2)
// Substitute for f1
λx2. (λx1. x2 x1)
And there I am stuck. I have lost both f
's, left with x
's only, and I haven't got 1 back. Where am I going wrong?
回答1:
Where am I going wrong?
Nowhere! You're done. Remember, the variable names aren't important; it's the structure that is important. The names f
or x2
aren't meaningful. It only matters how they are used. The Church numeral for 1 is
λf. λx. f x
and you have
λx2. (λx1. x2 x1)
Rename x2
to f
and x1
to x
and voilà! You have
λf. (λx. f x)
= λf. λx. f x
来源:https://stackoverflow.com/questions/1051033/lambda-calculus-and-church-numerals-confusion