Monday, 26 May 2025

Chapter 1 - Exercise 14

Exercise 1.14

The term ‘If x then u else v’ is represented by λx. xuv. Check this by calculating the β-normal forms of $(λx. xuv) \; true$ and $(λx. xuv) \; false$, respectively. (The booleans true and false are defined in Exercise 1.12.)


Let's try this with true.

$$\begin{align} (λx. xuv) \; true & = (λx. xuv) (λab.a) \\ \\ & \to  (λab.a) u v  \\ \\ & \to u \end{align}$$

That worked!


Now let's try it with false.

$$\begin{align} (λx. xuv) \; false & = (λx. xuv) (λab.b) \\ \\ & \to  (λab.b) u v  \\ \\ & \to v \end{align}$$

That also worked!