X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=week1.mdwn;h=c13fa7ca8787de96d87d81694544064fa1654522;hp=af079edf543c975f90a646c8d4ea6a8625cd6454;hb=93600ef645fa8bbb304288ea2161ec06b017762e;hpb=2b49dd93ee877d3a9f868933c9113fbbda94df88 diff --git a/week1.mdwn b/week1.mdwn index af079edf..c13fa7ca 100644 --- a/week1.mdwn +++ b/week1.mdwn @@ -57,13 +57,24 @@ We'll tend to write (λa M) as just `(\a M)`, so we don't hav Application: (M N) -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: -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: + 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: - ((\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**. @@ -274,17 +285,20 @@ 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 and false = false - * and true = * - * and * = * - * and false = * - false and true = false - 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.) +

+true and true   = true
+true and true   = true
+true and *      = *
+true and false  = false
+* and true      = *
+* and *         = *
+* and false     = *
+false and true  = false
+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 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: @@ -476,7 +490,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)) @@ -589,7 +603,6 @@ Here's how it looks to say the same thing in various of these languages. 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 OCaml permits you to abbreviate: @@ -638,6 +651,8 @@ Here's how it looks to say the same thing in various of these languages. or in other words, interpret the rest of the file or interactive session with `bar` assigned the function `(lambda (x) B)`. + Some more comparisons between Scheme and OCaml ---------------------------------------------- @@ -778,6 +794,8 @@ 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."