can tell me results of these lambda expressions when substitute x=5
?
a) λx. ((λx.x+1) x) b) (λx. (λx.x+1)) x
here think.
a) λx. (λx.x+1) x)5 = (λx.x+1) 5 = 6
b) (λx. (λx.x+1)) x 5 = (λx.x+1) x 5 = (λx.x+1) 5 = 6
the first expression:
(λx. (λx. x + 1) x) 5 = (λx. (λy. y + 1) x) 5 -- alpha renaming = (λy. y + 1) 5 -- beta reduction = 5 + 1 -- beta reduction = 6
the second expression:
((λx. λx. x + 1) x) 5 = ((λx. λy. y + 1) z) 5 -- alpha renaming (z free variable) = ( λy. y + 1 ) 5 -- beta reduction (z disappears because x never used) = 5 + 1 -- beta reduction = 6
hope helps.
Comments
Post a Comment