week1: shorthand tweaks
[lambda.git] / week1.mdwn
index 1bc2309..a181ea6 100644 (file)
@@ -74,7 +74,7 @@ The lambda calculus has an associated proof theory. For now, we can regard the
 proof theory as having just one rule, called the rule of **beta-reduction** or
 "beta-contraction". Suppose you have some expression of the form:
 
-       ((\ a M) N)
+       ((\a M) N)
 
 that is, an application of an abstract to some other expression. This compound form is called a **redex**, meaning it's a "beta-reducible expression." `(\a M)` is called the **head** of the redex; `N` is called the **argument**, and `M` is called the **body**.
 
@@ -154,47 +154,53 @@ Shorthand
 The grammar we gave for the lambda calculus leads to some verbosity. There are several informal conventions in widespread use, which enable the language to be written more compactly. (If you like, you could instead articulate a formal grammar which incorporates these additional conventions. Instead of showing it to you, we'll leave it as an exercise for those so inclined.)
 
 
-**Dot notation** Dot means "put a left paren here, and put the right
-paren as far the right as possible without creating unbalanced
-parentheses". So:
+**Parentheses** Outermost parentheses around applications can be dropped. Moreover, applications will associate to the left, so `M N P` will be understood as `((M N) P)`. Finally, you can drop parentheses around abstracts, but not when they're part of an application. So you can abbreviate:
 
-       (\x (\y (x y)))
+       (\x (x y))
 
-can be abbreviated as:
+as:
 
-       (\x (\y. x y))
+       \x (x y)
+
+but you should include the parentheses in:
+
+       (\x (x y)) z
 
 and:
 
-       (\x (\y. (z y) z))
+       z (\x (x y))
 
-would abbreviate:
 
-       (\x (\y ((z y) z)))
+**Dot notation** Dot means "put a left paren here, and put the right
+paren as far the right as possible without creating unbalanced
+parentheses". So:
 
-This on the other hand:
+       \x (\y (x y))
 
-       (\x (\y. z y) z)
+can be abbreviated as:
 
-would abbreviate:
+       \x (\y. x y)
 
-       (\x (\y (z y)) z)
+and that as:
 
-**Parentheses** Outermost parentheses around applications can be dropped. Moreover, applications will associate to the left, so `M N P` will be understood as `((M N) P)`. Finally, you can drop parentheses around abstracts, but not when they're part of an application. So you can abbreviate:
+       \x. \y. x y
 
-       (\x. x y)
+This:
 
-as:
+       \x. \y. (x y) x
 
-       \x. x y
+abbreviates:
 
-but you should include the parentheses in:
+       \x (\y ((x y) x))
 
-       (\x. x y) z
+This on the other hand:
 
-and:
+       (\x. \y. (x y)) x
+
+abbreviates:
+
+       ((\x (\y (x y))) x)
 
-       z (\x. x y)
 
 **Merging lambdas** An expression of the form `(\x (\y M))`, or equivalently, `(\x. \y. M)`, can be abbreviated as:
 
@@ -286,7 +292,6 @@ It's possible to enhance the lambda calculus so that functions do get identified
 It's often said that dynamic systems are distinguished because they are the ones in which **order matters**. However, there are many ways in which order can matter. If we have a trivalent boolean system, for example---easily had in a purely functional calculus---we might choose to give a truth-table like this for "and":
 
        true and true   = true
-       true and true   = true
        true and *      = *
        true and false  = false
        * and true      = *
@@ -539,7 +544,7 @@ Here's how it looks to say the same thing in various of these languages.
 
                (let* [(bar (lambda (x) B))] M)
 
-       then wherever `bar` occurs in `M` (and isn't rebound by a more local "let" or "lambda"), it will be interpreted as the function `(lambda (x) B)`.
+       then wherever `bar` occurs in `M` (and isn't rebound by a more local `let` or `lambda`), it will be interpreted as the function `(lambda (x) B)`.
 
        Similarly, in OCaml:
 
@@ -599,7 +604,7 @@ Here's how it looks to say the same thing in various of these languages.
                let x = A;;
                ... rest of the file or interactive session ...
 
-       It's easy to be lulled into thinking this is a kind of imperative construction. *But it's not!* It's really just a shorthand for the compound "let"-expressions we've already been looking at, taking the maximum syntactically permissible scope. (Compare the "dot" convention in the lambda calculus, discussed above.)
+       It's easy to be lulled into thinking this is a kind of imperative construction. *But it's not!* It's really just a shorthand for the compound `let`-expressions we've already been looking at, taking the maximum syntactically permissible scope. (Compare the "dot" convention in the lambda calculus, discussed above.)
 
 9.     Some shorthand
 
@@ -749,7 +754,7 @@ Or even:
        (define foo B)
        (foo 2)
 
-don't involve any changes or sequencing in the sense we're trying to identify. As we said, these programs are just syntactic variants of (single) compound syntactic structures involving "let"s and "lambda"s.
+don't involve any changes or sequencing in the sense we're trying to identify. As we said, these programs are just syntactic variants of (single) compound syntactic structures involving `let`s and `lambda`s.
 
 Since Scheme and OCaml also do permit imperatival constructions, they do have syntax for genuine sequencing. In Scheme it looks like this:
 
@@ -790,18 +795,3 @@ We'll discuss this more as the seminar proceeds.
 
 
 
-1.     Declarative vs imperatival models of computation.
-2.     Variety of ways in which "order can matter."
-3.     Variety of meanings for "dynamic."
-4.     Schoenfinkel, Curry, Church: a brief history
-5.     Functions as "first-class values"
-6.     "Curried" functions
-
-1.     Beta reduction
-1.     Encoding pairs (and triples and ...)
-1.     Encoding booleans
-
-
-
-
-