Minor cleanup

This commit is contained in:
2023-10-04 09:42:09 -07:00
parent 0744a88c00
commit ab410dbe74
6 changed files with 73 additions and 71 deletions

View File

@ -1,13 +1,13 @@
\section{Definitions}
\generic{$\lm$ Notation:}
$\lm$ notation is used to define functions, and looks like $(\lm ~ \text{input} ~ . ~ \text{output})$. \\
$\lm$ notation is used to define functions, and looks like $(\lm ~ \text{input} ~ . ~ \text{output})$. \par
Consider the following statement:
$$
I = \lm a . a
$$
This tells us that $I$ is a function that takes its input, $a$, to itself. We'll call this the \textit{identity function}. \\
This tells us that $I$ is a function that takes its input, $a$, to itself. We'll call this the \textit{identity function}.
To apply functions, put them next to their inputs. We'll omit the usual parentheses to save space.
@ -27,7 +27,8 @@ $$
\end{tikzpicture}
$$
Functions are left-associative: If $A$ and $B$ are functions, $(A~B~\star)$ is equivalent to $((A~B)~\star)$. As usual, we'll use parentheses to group terms if we want to override this order: $(A~(B~\star)) \neq (A~B~\star)$ \\
Functions are left-associative: If $A$ and $B$ are functions, $(A~B~\star)$ is equivalent to $((A~B)~\star)$.
As usual, we'll use parentheses to group terms if we want to override this order: $(A~(B~\star)) \neq (A~B~\star)$ \par
In this handout, all types of parentheses ( $(), [],$ etc ) are equivalent.
\vfill
@ -88,8 +89,7 @@ Before we begin, let's review \textit{function composition}. With \say{normal} f
\vspace{1ex}
To demonstrate currying, we'll make a function $C$ in lambda calculus, which takes two functions ($f$ and $g$), an input $x$, and produces $f$ applied to $g$ applied to $x$. \\
To demonstrate currying, we'll make a function $C$ in lambda calculus, which takes two functions ($f$ and $g$), an input $x$, and produces $f$ applied to $g$ applied to $x$. \par
In other words, we want a $C$ so that $C~f~g~x = f~(g~x)$
\vspace{1ex}
@ -101,7 +101,7 @@ $$
\vspace{1ex}
This looks awfully scary, so let's take this expression apart. \\
This looks awfully scary, so let's take this expression apart. \par
C is a function that takes one argument ($f$) and returns a function (underlined):
$$
C = \lm f .(~~\tzm{a} \lm g . (\lm x . f(g(x))) \tzm{b}~~)
@ -138,7 +138,7 @@ This last function $\lm x. f(g(x))$ takes one argument, and returns $f(g(x))$. S
\vspace{2ex}
So, currying allows us to create multivariable functions by nesting single-variable functions. \\
So, currying allows us to create multivariable functions by nesting single-variable functions. \par
As you saw above, such expressions can get very long. We'll use a bit of shorthand to make them more palatable. If we have an expression with repeated function definitions, we'll combine their arguments under one $\lm$.
\vspace{1ex}
@ -154,11 +154,12 @@ $$
\vspace{1ex}
This is only notation. \textbf{Curried functions are not multivariable functions!} They must be evaluated one variable at a time, just like their un-curried version. Substituting all curried variables in one go may cause errors, as you'll see below.
This is only notation. \textbf{Curried functions are not multivariable functions!} They must be evaluated one variable at a time, just like their un-curried version.
Substituting all curried variables in one go may cause errors, as you'll see below.
\problem{}
Evaluate $C~M~I~\star$ \\
Then, evaluate $C~I~M~I$ \\
Evaluate $C~M~I~\star$ \par
Then, evaluate $C~I~M~I$ \par
\hint{Place parentheses first. Remember, function application is left-associative.}
@ -174,8 +175,8 @@ $I = \lm a.a = \lm b.b = \lm \heartsuit . \heartsuit = ...$
Variables inside functions are \say{scoped.} We must take care to keep separate variables separate.
For example, take the functions \\
$A = \lm a b . a$ \\
For example, take the functions \par
$A = \lm a b . a$ \par
$B = \lm b . b$
\vspace{2ex}
@ -214,7 +215,7 @@ $$
Now, we correctly find that $(A~B~I) = (\lm bc . c)~I = \lm c . c = B = I$.
\problem{}
Let $C = \lm abc.b$ \\
Let $C = \lm abc.b$ \par
Reduce $(C~a~c~b)$.
\begin{solution}