2025 James B. Wilson
\(I(x) = x\)
\(K_c(x)=c\)
So
\(K_x(x)=x\)?
A motivated introduction to \(\lambda\)-calculus
A fable by James B. Wilson
Every day Haskell Curry and Robert Feys would go to lunch at Constants.
The menu was always the one posted item.
On Curry days, Haskell was happy.
...but Robert would be sad.
A fable by James B. Wilson
On Fry days, Robert was delighted...
...but Haskell was mad.
A fable by James B. Wilson
Then one day the two of them had and idea!
Replace the menu with a variable so they could both order what they wanted!
Constant functions are
Graph is a horizontal line (Slope 0).
(Thanks to Desmos.com)
\(c\) in \(K_c(x)=c\) is a place-holder for some future choice.
(Thanks to Desmos.com)
I'm going to choose \(c:=x\).
\(K_x(x)=x\)
Graph that ...
IT HAS SLOPE 1!
Constant functions DON'T have slope 1, so what's the mistake?
\(x\) from alphabet of variables
\(a\) from separate alphabet of constants
\(\sigma\) a string of variables, constants, and the \(\mapsto\) symbol.
3. \(\begin{aligned} x7|_{x:=35+y} & \rhd (x|_{x:=35+y})(7|_{x:=35+y})\\ & \rhd (35+y)7\end{aligned}\)
2. \(5|_{x:=35+y}\rhd 5\)
Technical point, the parentheses, \(|\), \(:=\), and \(\rhd\) are outside the language, they are "meta-language".
> x:=35+y
> x
35+y
> x:=35+y
> 27
27
> x:=35+y
> (x-5)(x+5)
(35+y-5)(35+y+5)
\[\begin{aligned} (x\mapsto x^2)|_{x:=35+y} & \rhd (x\mapsto x^2)\end{aligned}\]
x := 35+y
def f(x)
return x*x
Not the "same" x.
4. Local Variables are invisible from outside scope: \[(x\mapsto \tau)|_{x:=\sigma}\qquad \text{yields}\qquad x\mapsto \tau\]
Not the "same" \(x\).
(More confusing in math notation.)
def f(x)
return x*x
x := 35+y
def f(y)
s := 0
for x in [1..10]
s := y*x
return s
Not the "same" x.
5. Avoid Trapping variables!
def f(y)
s := 0
for x in [1..10]
s := y*x
return s
x := 35+pi
def f(y)
return y + x
SAME x.
If \(x\) is in \(\tau\) but free, then avoid trapping variables!
def f(y)
return y + (35+pi)
No "visible" y.
x := 35+y
def f(y)
return y + x
SAME x.
def f(y)
return y + (35+y)
y is visible (free)!
x := 35+y
def f(z)
return z + (35+y)
Not the same y.
x := 35+pi
def f(y)
return y + x
SAME x.
No "visible" y,
so not trapped
x := 35+y
def f(y)
return y + x
SAME x.
y is visible (free)!
So it is trapped between same x's
SAME x=c.
No "visible" x,
so not trapped
\(c:=5\)
\(K_c(x)=c\)
SAME x=c.
"visible" x,
trapped;
rename!
\(c:=x\)
\(K_c(x)=c\)
\(c:=x\)
\(K_c(z)=c\);
So \(K_x(z)=x\)
(still slope 0, but in the zx-plane)
\(K_5(x)=5\)
(....be honest, did you really know that?)