8
$\begingroup$

My students are pretty confused by lambda calculus. I'm looking for a way to start them off. Is there some image or analogy for lambda calculus that I can use to help them understand in the beginning?

My kids are college sophomores, and I would just like to give them a clear way to start thinking about it.

$\endgroup$
  • 2
    $\begingroup$ Welcome to CSE.SE! This question needs some more detail. What is the level of the students in question? And are you literally only asking for an opener? $\endgroup$ – Ben I. Jun 12 '17 at 21:05
  • 2
    $\begingroup$ It would help us to give better answers if you could tell us the general methods you have tried, and what seems to be the part that they don't grasp. It would also be help if you told us the context for this. Is it in preparation for a functional language, or for closures in a procedural language, or some other context entirely? $\endgroup$ – Gypsy Spellweaver Jun 12 '17 at 22:48
  • $\begingroup$ How does teaching the Lambda Calculus differ from teaching about functions in math? $\endgroup$ – Ellen Spertus Jun 15 '17 at 3:05
  • $\begingroup$ I know you asked about images and analogies, not code, but are you using Scheme? It's essentially an interpreter for the Lambda Calculus. $\endgroup$ – Ellen Spertus Jun 15 '17 at 3:06
  • 1
    $\begingroup$ Math: The "There exists" and "For all it is true" equations (don't know how to make the actual symbols here) do the exact same thing as lambda expressions. $\endgroup$ – Thorbjørn Ravn Andersen Jul 7 '17 at 18:16
4
$\begingroup$

One totally intuitive way to introduce the concept is with Excel formulas. So, imagine in A1, we have the value 10. In B1, we have the formula =power(A1,2), and in B2, we have the formula =(A1+A1)/A1. So, at this point, our sheet looks like this:

        A   B   C
    1   10  100
    2       2

In actuality, we have now created a literal, and two lambda expressions: $10$, $(\lambda x.(power\, x\, 2))$ and $(\lambda x.(/\, (+\, x\, x)\, x))$.

Now, let's add a formula into C1. That formula will be: =B1+1. This is a third $\lambda$ expression: $(\lambda x.(+\, x\, 1))$. Our sheet now looks like this:

        A   B   C
    1   10  100 101
    2       2

Since we are pointing C1 to B1, which itself points to A1, we have now created $(\lambda x.(+\, x\, 1))\, (\lambda x.(power\, x\, 2))\, 10$, which resolves now in exactly the way you would expect from the Excel formulas:

$(\lambda x.(+\, x\, 1))\, (\lambda x.(power\, x\, 2))\, 10$

$(\lambda x.(+\, x\, 1))\, (power\, 10\, 2)$

$(+\, (power\, 10\, 2)\, 1))$

$(+\, 100\, 1))$

$101$

Simply re-pointing C1 to B2 gives us a new lambda expression:

$(\lambda x.(+\, x\, 1))\, (\lambda x.(/\, (+\, x\, x)\, x))\, 10$

Which again, resolves to 3 as you would expect.

What's nice here is that if you get rid of the 10 in A1 (you must replace it with a non-number so that Excel does not convert it to 0), you will get #VALUE, because you have created a $lambda$ expression, but not fed in the rightmost value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.