deleted monday notes
[lambda.git] / week1.mdwn
index db74d7c..a181ea6 100644 (file)
@@ -57,13 +57,22 @@ We'll tend to write <code>(&lambda;a M)</code> as just `(\a M)`, so we don't hav
 <strong>Application</strong>: <code>(M N)</code>
 </blockquote>
 
-Some authors reserve the term "term" for just variables and abstracts. We won't participate in that convention; we'll probably just say "term" and "expression" indiscriminately for expressions of any of these three forms.
+Some authors reserve the term "term" for just variables and abstracts. We'll probably just say "term" and "expression" indiscriminately for expressions of any of these three forms.
 
-Samples of expressions:
+Examples of expressions:
 
-       foo
+       x
+       (y x)
+       (x x)
+       (\x y)
+       (\x x)
+       (\x (\y x))
+       (x (\x x))
+       ((\x (x x)) (\x (x x)))
 
-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:
+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)
 
@@ -145,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 (x y)
+
+but you should include the parentheses in:
 
-       (\x (\y. x y))
+       (\x (x y)) z
 
 and:
 
-       (\x (\y. (z y) z))
+       z (\x (x y))
+
+
+**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:
 
-would abbreviate:
+       \x (\y (x y))
 
-       (\x (\y ((z y) z)))
+can be abbreviated as:
 
-This on the other hand:
+       \x (\y. x y)
 
-       (\x (\y. z y) z)
+and that as:
 
-would abbreviate:
+       \x. \y. x y
 
-       (\x (\y (z y)) z)
+This:
 
-**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. x y)
+abbreviates:
 
-as:
+       \x (\y ((x y) x))
 
-       \x. x y
+This on the other hand:
 
-but you should include the parentheses in:
+       (\x. \y. (x y)) x
 
-       (\x. x y) z
+abbreviates:
 
-and:
+       ((\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 +301,7 @@ It's often said that dynamic systems are distinguished because they are the ones
        false and *     = false
        false and false = false
 
-And then we'd notice that `* and false` has a different intepretation than `false and *`. (The same phenomenon is already present with the mateial conditional in bivalent logics; but seeing that a non-symmetric semantics for `and` is available even for functional languages is instructive.)
+And then we'd notice that `* and false` has a different intepretation than `false and *`. (The same phenomenon is already present with the material conditional in bivalent logics; but seeing that a non-symmetric semantics for `and` is available even for functional languages is instructive.)
 
 Another way in which order can matter that's present even in functional languages is that the interpretation of some complex expressions can depend on the order in which sub-expressions are evaluated. Evaluated in one order, the computations might never terminate (and so semantically we interpret them as having "the bottom value"---we'll discuss this). Evaluated in another order, they might have a perfectly mundane value. Here's an example, though we'll reserve discussion of it until later:
 
@@ -478,7 +493,7 @@ Here's how it looks to say the same thing in various of these languages.
                          (let ((two 2))
                                   (+ three two)))
 
-       Scheme also has a simple `let` (without the `*`), and it permits you to group several variable bindings together in a single `let`- or `let*`-statement, like this:
+       Scheme also has a simple `let` (without the ` *`), and it permits you to group several variable bindings together in a single `let`- or `let*`-statement, like this:
 
                (let* ((three 3) (two 2))
                          (+ three two))
@@ -529,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:
 
@@ -589,8 +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
 
@@ -662,9 +676,8 @@ Here's how it looks to say the same thing in various of these languages.
 
        and there's no more mutation going on there than there is in:
 
-       <pre>
-       <code>&forall;x. (F x or &forall;x (not (F x)))</code>
-       </pre>
+       <pre><code>&forall;x. (F x or &forall;x (not (F x)))
+       </code></pre>
 
        When a previously-bound variable is rebound in the way we see here, that's called **shadowing**: the outer binding is shadowed during the scope of the inner binding.
 
@@ -741,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:
 
@@ -780,18 +793,5 @@ contributes no more to a larger context in which it's embedded than C does. This
 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
-
-
-