cleanup
authorJim Pryor <profjim@jimpryor.net>
Thu, 23 Sep 2010 10:13:25 +0000 (06:13 -0400)
committerJim Pryor <profjim@jimpryor.net>
Thu, 23 Sep 2010 10:13:25 +0000 (06:13 -0400)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
code/caml-lambda/lambda.ml [moved from code/lambda.ml with 100% similarity]
code/caml-lambda/q_lambda.ml [moved from code/q_lambda.ml with 100% similarity]
code/sample.html [deleted file]
index.mdwn
offsite_reading.mdwn
using_the_programming_languages.mdwn [deleted file]

similarity index 100%
rename from code/lambda.ml
rename to code/caml-lambda/lambda.ml
diff --git a/code/sample.html b/code/sample.html
deleted file mode 100644 (file)
index 0f44885..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html><head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
-
-
-    <title>Top Down Operator Precedence</title>
-    <style>
-th {background-color: thistle; border: black solid 1px; text-align: left;
-    padding-left: 10px; padding-right: 10px; vertical-align: top;}
-td {background-color: white; border: black solid 1pt; padding-left: 10px;
-    padding-right: 10px; vertical-align: top;}
-table {width: 90%; border: 0px; cellpadding: 0px;}
-    </style>
-</head><body bgcolor="linen">
-<h1>Top Down Operator Precedence</h1>
-
-<p><a href="http://www.crockford.com/">Douglas Crockford</a></p>
-
-<p>2007-08-05</p>
-
-<h2>Demonstration</h2>
-<p>The text that follows is the parse tree that the parser generated by
-  parsing itself. </p>
-<textarea id="INPUT" style="border: 2px solid black; color: black; font-family: monospace; height: 3in; overflow: auto; padding: 0.5em; width: 100%;"></textarea>
-<input id="PARSE" value="parse" type="button">
-<noscript><p>You may not see it because you have JavaScript turned off. Uffff!</p></noscript>
-<script src="tokens.js"></script>
-<script src="parse.js"></script>
-<script src="lambda2.js"></script>
-<script src="json2.js"></script>
-<pre id="OUTPUT">
-</pre>
-<script>
-/*jslint evil: true */
-
-/*members create, error, message, name, prototype, stringify, toSource,
-    toString, write
-*/
-
-/*global JSON, make_parse, parse, source, tree */
-
-// Make a new object that inherits members from an existing object.
-
-if (typeof Object.create !== 'function') {
-    Object.create = function (o) {
-        function F() {}
-        F.prototype = o;
-        return new F();
-    };
-}
-
-// Transform a token object into an exception object and throw it.
-
-Object.prototype.error = function (message, t) {
-    t = t || this;
-    t.name = "SyntaxError";
-    t.message = message;
-    throw t;
-};
-
-
-(function () {
-    var parse = make_parse();
-
-    function go(source) {
-        var string, tree;
-        try {
-            tree = parse(source);
-//             string = JSON.stringify(tree, ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
-//             string = JSON.stringify(tree.handler(), ['key', 'name', 'message', 'value', 'arity', 'first', 'second', 'tag', 'variable', 'left', 'right', 'bound', 'body' ], 4);
-                       string = tree.handler().to_string();
-        } catch (e) {
-            string = JSON.stringify(e, ['name', 'message', 'from', 'to', 'key',
-                    'value', 'arity', 'first', 'second', 'third', 'fourth'], 4);
-        }
-        document.getElementById('OUTPUT').innerHTML = string
-            .replace(/&/g, '&amp;')
-            .replace(/[<]/g, '&lt;');
-    }
-
-//     go("var make_parse = " + (make_parse.toSource ?
-//             make_parse.toSource() : make_parse.toString()) + ";");
-
-    document.getElementById('PARSE').onclick = function (e) {
-        go(document.getElementById('INPUT').value);
-    };
-}());
-
-</script>
-
-</body></html>
index 7c75223..28fc8c4 100644 (file)
@@ -10,11 +10,21 @@ This course will be co-taught by [Chris Barker](http://homepages.nyu.edu/~cb125/
 The seminar meets on Mondays from 4-6, in 
 the Linguistics building at 10 Washington Place, in room 104 (back of the first floor).
 
 The seminar meets on Mondays from 4-6, in 
 the Linguistics building at 10 Washington Place, in room 104 (back of the first floor).
 
-We've sent around an email to those who left their email addresses on the roster we passed around. But it's clear that the roster didn't make its way to everyone. So if you didn't receive our email this evening, please email <mailto:jim.pryor@nyu.edu> with your email address, and if you're a student, say whether you expect to audit or take the class for credit.
-
 Student sessions will be held on Tuesdays from 11-12 and Wednesdays from 3-4. (You only need attend one session.) You should see these sessions as opportunities to clear up lingering issues from material we've discussed, and help get a better footing for what we'll be doing the next week. It would be smart to make a serious start on that week's homework, for instance, before the session.
 
 Student sessions will be held on Tuesdays from 11-12 and Wednesdays from 3-4. (You only need attend one session.) You should see these sessions as opportunities to clear up lingering issues from material we've discussed, and help get a better footing for what we'll be doing the next week. It would be smart to make a serious start on that week's homework, for instance, before the session.
 
-Lots of lecture notes summarizing and expanding on last Monday's seminar now posted. Also, lecture notes for upcoming session have been posted. (Click "Notes and Schedule".)
+We've sent around an email to those who left their email addresses on the roster we passed around. But it's clear that the roster didn't make its way to everyone. So if you're not receiving our seminar emails, please email <mailto:jim.pryor@nyu.edu> with your email address, and if you're a student, say whether you expect to audit or take the class for credit.
+
+There is now a [[lambda evaluator]] you can use in your browser (no need to install any software).
+It can help you check whether your answer to some of the homework questions works correctly.
+
+<!--
+  To play around with a **typed lambda calculus**, which we'll look at later
+  in the course, have a look at the [Penn Lambda Calculator](http://www.ling.upenn.edu/lambda/).
+  This requires installing Java, but provides a number of tools for evaluating
+  lambda expressions and other linguistic forms. (Mac users will most likely
+  already have Java installed.)
+-->
+
 
 ## Lecture Notes and Assignments ##
 
 
 ## Lecture Notes and Assignments ##
 
@@ -26,9 +36,6 @@ Topics: Applications; Basics of Lambda Calculus; Comparing Different Languages
 
 Topics: Reduction and Convertibility; Combinators; Evaluation Strategies and Normalization; Decidability; Lists and Numbers
 
 
 Topics: Reduction and Convertibility; Combinators; Evaluation Strategies and Normalization; Decidability; Lists and Numbers
 
-There is now a [[lambda evaluator]] you can use in your browser (no need to install any software).
-It can help you check whether your answer to some of the homework questions works correctly.
-
 (27 Sept) ...(Notes to come) 
 Topics: Recursion with Fixed Point Combinators
 
 (27 Sept) ...(Notes to come) 
 Topics: Recursion with Fixed Point Combinators
 
index 0c6a19d..d9c7f82 100644 (file)
@@ -46,6 +46,7 @@ get more out of. (Rinse and repeat.)
 ## Untyped lambda calculus and combinatory logic ##
 
 *      [[!wikipedia Lambda calculus]]
 ## Untyped lambda calculus and combinatory logic ##
 
 *      [[!wikipedia Lambda calculus]]
+*      Our [[Lambda evaluator]]
 *      [Chris Barker's Lambda Tutorial](http://homepages.nyu.edu/~cb125/Lambda)
 *      [Lambda Animator](http://thyer.name/lambda-animator/)
 *      [Penn lambda calculator](http://www.ling.upenn.edu/lambda/) Pedagogical software developed by Lucas Champollion, Josh Tauberer and Maribel Romero.<p>
 *      [Chris Barker's Lambda Tutorial](http://homepages.nyu.edu/~cb125/Lambda)
 *      [Lambda Animator](http://thyer.name/lambda-animator/)
 *      [Penn lambda calculator](http://www.ling.upenn.edu/lambda/) Pedagogical software developed by Lucas Champollion, Josh Tauberer and Maribel Romero.<p>
diff --git a/using_the_programming_languages.mdwn b/using_the_programming_languages.mdwn
deleted file mode 100644 (file)
index 6952e49..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-
-## Programming in the pure untyped lambda calculus ##
-
-There are several ways to do this.
-
-1.     The easiest is to use a JavaScript interpreter that Chris wrote. Go [here](/lambda-let.html) and follow the template:
-       
-               let true = (\x (\y x)) in
-               let false = (\x (\y y)) in
-               let and = (\l (\r ((l r) false))) in
-
-               (
-
-                       ((((and false) false) yes) no)
-
-                       ((((and false) true) yes) no)
-
-                       ((((and true) false) yes) no)
-
-                       ((((and true) true) yes) no)
-
-               )
-       
-       will evaluate to:
-       
-               (no no no yes)
-
-       If you try to evaluate a non-terminating form, like `((\x (x x)) (\x (x x)))`, you'll probably have to force-quit your browser and start over. Anything you had earlier typed in the upper box will probably be lost.
-
-       Syntax: you have to fully specify parentheses and separate your lambdas. So for example, you can't write `(\x y. y)`; you have to write `(\x (\y y))`. The parser treats symbols that haven't yet been bound (as `yes` and `no` above) as free variables.
-
-
-2.     A bit more flexibility and robustness can be had by using an OCaml package. This is based on a library on [a Haskell library by Oleg Kiselyov](http://okmij.org/ftp/Computation/lambda-calc.html#lambda-calculator-haskell).
-
-       Jim converted this to OCaml and bundled it with a syntax extension that makes
-it easier to write pure untyped lambda expressions in OCaml. You don't have to
-know much OCaml yet to use it. Using it looks like this:
-
-               let zero = << fun s z -> z >>;;
-               let succ = << fun n s z -> s (n s z) >>;;
-               let one = << $succ$ $zero$ >>;;
-               let two = << $succ$ $one$ >>;;
-               let add = << fun m n -> n $succ$ m >>;;
-               (* or *)
-               let add = << fun m n -> fun s z -> m s (n s z) >>;;
-               .
-               (* now use:
-                       pp FORMULA                              to print a formula, unreduced
-                       pn FORMULA                              to print the normal form of a formula (when possible)
-                       pi FORMULA                              to print the integer which FORMULA is a Church numeral for (when possible)
-               .
-                       alpha_eq FORM1 FORM2    are FORM1 and FORM2 syntactically equivalent (up to alpha-conversion)?
-                                                                       this does not do reductions on the formulae
-               *)
-               .
-               pi << $add$ $one$ $two$ >>;;
-               - : int = 3
-
-       To install this package, here's what you need to do. I've tried to explain it in basic terms, but you do need some familiarity with your operating system: for instance, how to open a Terminal window, how to figure out what directory the Terminal is open to (use `pwd`); how to change directories (use `cd`); and so on.
-
-       INCLUDE INSTRUCTIONS
-
-       We assume here that you've already [gotten OCaml installed on your computer](/how_to_get_the_programming_languages_running_on_your_computer/).
-
-       Some notes:
-
-       *       When you're talking to the interactive OCaml program, you have to finish complete statements with a ";;". Sometimes these aren't necessary, but rather than learn the rules yet about when you can get away without them, it's easiest to just use them consistently, like a period at the end of a sentence.
-
-       *       What's written betwen the `<<` and `>>` is parsed as an expression in the pure untyped lambda calculus. The stuff outside the angle brackets is regular OCaml syntax. Here you only need to use a very small part of that syntax: `let var = some_value;;` assigns a value to a variable, and `function_foo arg1 arg2` applies the specified function to the specified arguments. `church_to_int` is a function that takes a single argument --- the lambda expression that follows it, `<< $add$ $one$ $two$ >>` -- and, if that expression when fully reduced or "normalized" has the form of a "Church numeral", it converts it into an "int", which is OCaml's (and most language's) primitive way to represent small numbers. The line `- : int = 3` is OCaml telling you that the expression you just had it evaluate simplifies to a value whose type is "int" and which in particular is the int 3.
-
-       *       If you call `church_to_int` with a lambda expression that doesn't have the form of a Church numeral, it will complain. If you call it with something that's not even a lambda expression, it will complain in a different way.
-
-       *       The `$`s inside the `<<` and `>>` are essentially corner quotes. If we do this: `let a = << x >>;; let b = << a >>;; let c = << $a$ >>;;` then the OCaml variable `b` will have as its value an (atomic) lambda expression, consisting just of the variable `a` in the untyped lambda calculus. On the other hand, the OCaml variable `c` will have as its value a lambda expression consisting just of the variable `x`. That is, here the value of the OCaml variable `a` is spliced into the lambda expression `<< $a$ >>`.
-
-       *       The expression that's spliced in is done so as a single syntactic unit. In other words, the lambda expression `<< w x y z >>` is parsed via usual conventions as `<< (((w x) y) z) >>`. Here `<< x y >>` is not any single syntactic constituent. But if you do instead `let a = << x y >>;; let b = << w $a$ z >>`, then what you get *will* have `<< x y >>` as a constituent, and will be parsed as `<< ((w (x y)) z) >>`.
-
-       *       `<< fun x y -> something >>` is equivalent to `<< fun x -> fun y -> something >>`, which is parsed as `<< fun x -> (fun y -> (something)) >>` (everything to the right of the arrow as far as possible is considered together). At the moment, this only works for up to five variables, as in `<< fun x1 x2 x3 x4 x5 -> something >>`.
-
-       *       The `<< >>` and `$`-quotes aren't part of standard OCaml syntax, they're provided by this add-on bundle. For the most part it doesn't matter if other expressions are placed flush beside the `<<` and `>>`: you can do either `<< fun x -> x >>` or `<<fun x->x>>`. But the `$`s *must* be separated from the `<<` and `>>` brackets with spaces or `(` `)`s. It's probably easiest to just always surround the `<<` and `>>` with spaces.
-
-
-<!--
-
-There are several ways to do this, and we're still thinking out loud in this space about which method we should recommend you use.
-
-1.     To get started, Chris has a nice [Lambda Tutorial](http://homepages.nyu.edu/~cb125/Lambda)
-webpage introducing the untyped lambda calculus. This page has embedded Javascript
-code that enables you to type lambda expressions into your web browser page
-and click a button to "execute" (that is, reduce or normalize) it.
-
-       To do more than a few simple exercises, though, you'll need something more complex.
-
-2.     One option is to use a short Scheme macro, like the one [linked at the bottom of Chris' webpage](http://homepages.nyu.edu/~cb125/Lambda/lambda.scm).
-You can use this by loading into a Scheme interpreter (EXPLAIN HOW...) and then (STEP BY STEP...).
-
-       Here's Chris' explanation of the macro:
-
-               (define (reduce f)                                                          ; 1
-                 ((lambda (value) (if (equal? value f) f (reduce value)))                  ; 2
-                  (let r ((f f) (g ()))                                                    ; 3
-                        (cond ((not (pair? f))                                                 ; 4
-                                       (if (null? g) f (if (eq? f (car g)) (cadr g) (r f (caddr g))))) ; 5
-                                  ((and (pair? (car f)) (= 2 (length f)) (eq? 'lambda (caar f)))   ; 6
-                                       (r (caddar f) (list (cadar f) (r (cadr f) g) g)))               ; 7
-                                  ((and (not (null? g)) (= 3 (length f)) (eq? 'lambda (car f)))    ; 8
-                                       (cons 'lambda (r (cdr f) (list (cadr f) (delay (cadr f)) g))))  ; 9
-                                  (else (map (lambda (x) (r x g)) f))))))                          ;10
-               
-               If you have a Scheme interpreter, you can call the function like this:
-               
-               (reduce '(((lambda x (lambda y (x y))) 2) 3))
-               ;Value: (2 3)
-               
-               (reduce '((lambda x (lambda y (x y))) 2))
-               ;Value: (lambda #[promise 2] (2 #[promise 2]))
-               
-               Comments: f is the form to be evaluated, and g is the local assignment
-               function; g has the structure (variable value g2), where g2 contains the rest
-               of the assignments. The named let function r executes one pass through a form.
-               The arguments to r are a form f, and an assignment function g. Line 2: continue
-               to process the form until there are no more conversions left. Line 4
-               (substitution): If f is atomic [or if it is a promise], check to see if matches
-               any variable in g and if so replace it with the new value. Line 6 (beta
-               reduction): if f has the form ((lambda variable body) argument), it is a lambda
-               form being applied to an argument, so perform lambda conversion. Remember to
-               evaluate the argument too! Line 8 (alpha reduction): if f has the form (lambda
-               variable body), replace the variable and its free occurences in the body with a
-               unique object to prevent accidental variable collision. [In this implementation
-               a unique object is constructed by building a promise. Note that the identity of
-               the original variable can be recovered if you ever care by forcing the
-               promise.] Line 10: recurse down the subparts of f.
-
-
-3.     Oleg Kiselyov has a [richer lambda interpreter](http://okmij.org/ftp/Scheme/#lambda-calc) in Scheme. Here's how he describes it
-(I've made some trivial changes to the text):
-
-               A practical Lambda-calculator in Scheme
-               
-               The code below implements a normal-order interpreter for the untyped
-               lambda-calculus. The interpret permits "shortcuts" of terms. The shortcuts are
-               not first class and do not alter the semantics of the lambda-calculus. Yet they
-               make complex terms easier to define and apply.
-               
-               The code also includes a few convenience tools: tracing of all reduction,
-               comparing two terms modulo alpha-renaming, etc.
-               
-               This calculator implements a normal-order evaluator for the untyped
-               lambda-calculus with shortcuts. Shortcuts are distinguished constants that
-               represent terms. An association between a shortcut symbol and a term must be
-               declared before any term that contains the shortcut could be evaluated. The
-               declaration of a shortcut does not cause the corresponding term to be
-               evaluated. Therefore shortcut's term may contain other shortcuts -- or even yet
-               to be defined ones. Shortcuts make programming in lambda-calculus remarkably
-               more convenient.
-               
-               Besides terms to reduce, this lambda-calculator accepts a set of commands,
-               which add even more convenience. Commands define new shortcuts, activate
-               tracing of all reductions, compare terms modulo alpha-conversion, print all
-               defined shortcuts and evaluation flags, etc. Terms to evaluate and commands are
-               entered at a read-eval-print-loop (REPL) "prompt" -- or "included" from a file
-               by a special command.
-               
-               Examples
-               
-               First we define a few shortcuts:
-               
-                        (X Define %c0 (L s (L z z)))                     ; Church numeral 0
-                        (X Define %succ (L n (L s (L z (s (n z z))))))   ; Successor
-                        (X Define* %c1 (%succ %c0))
-                        (X Define* %c2 (%succ %c1))
-                        (X Define %add (L m (L n (L s (L z (m s (n s z))))))) ; Add two numerals
-               
-                       (%add %c1 %c2)
-               REPL reduces the term and prints the answer: (L f (L x (f (f (f x))))).
-               
-                        (X equal? (%succ %c0) %c1)
-                        (X equal?* (%succ %c0) %c1)
-               
-               The REPL executes the above commands and prints the answer: #f and #t,
-               correspondingly. The second command reduces the terms before comparing them.
-
-       See also <http://okmij.org/ftp/Computation/lambda-calc.html>.
-
-
-5.     To play around with a **typed lambda calculus**, which we'll look at later
-in the course, have a look at the [Penn Lambda Calculator](http://www.ling.upenn.edu/lambda/).
-This requires installing Java, but provides a number of tools for evaluating
-lambda expressions and other linguistic forms. (Mac users will most likely
-already have Java installed.)
-
-## Reading about Scheme ##
-
-[R5RS Scheme](http://people.csail.mit.edu/jaffer/r5rs_toc.html)
-
-## Reading about OCaml ##
-
--->
-
-