Lambda Calculus: Reduction to Normal Form

350 Views Asked by At

I'm working on some problems where I'm supposed to reduce lamda terms to normal form. I'm not sure if I'm doing it right so if someone could let me know, that would be awesome.

$$(\lambda x.\lambda y.x*2+y*3)\; 5 \;4 $$

$$\rightarrow(\lambda y.5*2+y*3) \; 4 $$

$$\rightarrow(5*2+4*3) $$

$$\rightarrow 22$$

And secondly, how does that equation differ from $\lambda x.(\lambda y.x*2+y*3) \; 5$? They just moved the parenthesis over $1\ldots$ does that mean the $λx$ would just stay in the answer? as in:

$$\lambda x.(\lambda y.x*2+y*3) 5$$

$$\rightarrow\lambda x.(x*2+5*3)$$

And would I solve it to be:

$$\rightarrow \lambda x.(x*2+15)$$

Thanks in advance,

Sean

1

There are 1 best solutions below

5
On BEST ANSWER

Yes, you are right.

Let $$f = \lambda x.\ \lambda y.\ x\cdot 2 + y \cdot 3,$$ that is, (using different notation) we have $f(x)(y) = 2x+3y$, and so $(f\ 5\ 4) = f(5)(4) = 10+12 = 22$. On the other hand, if you won't take whole $f$ into parentheses, then we arrive at $$\Big(\lambda x.\ (\lambda y. x \cdot 2 + y \cdot 3)\ 5 \Big)= (\lambda x.\ x \cdot 2+15),$$ if we were to pass $4$ later, then we get $(\lambda x.\ x \cdot 2 + 15)\ 4 = 8+15 = 23$.

The difference is that the scope of $\lambda$ extends to as far right as possible, so the additional $5$ is under the scope of $\lambda x$. Hence, $5$ would be substituted into $y$. However, in the former example, the number $5$ was separated from both lambdas by parentheses, and so it would be substituted into $x$.

I hope this helps $\ddot\smile$