So I have this lambda expression: (λf.λx.f(f(f(x)))) (λg.λy.g(g(y)))(λz.z + 1)(0) and I'm trying to evaluate it by hand. They way I'm thinking about this is that (λf.λx.f(f(f(x)))) basically represents the expression f(f(f(x))). Then likewise (λg.λy.g(g(y))) represents the expression g(g(y)). Then g(g(y)) is passed in to replace f. So we get g(g(g(g(g(g(y)))))). Or g composed with itself 6 times. Then we pass in z+1 for g and then plug in 0 into that final expression and we wind up with 6.
>>>(((lambda f: lambda x: f(f(f(x))))(lambda g: lambda y: g(g(y))))(lambda z: z+1))(0)
8
The problem is that when I go to verify this answer using python's built in lambda calculus tools I get 8 as the answer.
So clearly I'm doing my evaluation wrong. I'm thinking of 2 g compositions being multiplied by 3 f compositions to get 6. But clearly I'm supposed to be thinking of it as 2^3 compositions but I don't understand why.