From: Jim Date: Tue, 10 Feb 2015 11:12:22 +0000 (-0500) Subject: Merge branch 'master' into working X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=07ebc9292a8db8b98707232d2d01717293f473e9;hp=2b7fba878488efb4de5bc4f3d8f895691ebfec34 Merge branch 'master' into working * master: (22 commits) rename exercises/assignment2_answers.mdwn to exercises/_assignment2_answers.mdwn just link to hint for `reverse` compare `cons` create page link to answers1 formatting, code style link to answers to week1 homework create solutions redo hint links removed create page create page reorganize, add some (as-yet-unlinked) titles for week 3 add anchors tweak explanation of why `f` is curried clarify why Lambda Calculus prefers curried functions, thanks for input Kyle 38e98c659e1819ddd4457935508ee12824b50241 edits to combinatory logic added old CL text clarify constraints ... --- diff --git a/exercises/assignment3.mdwn b/exercises/assignment3.mdwn index 271d2bfd..e2fd9627 100644 --- a/exercises/assignment3.mdwn +++ b/exercises/assignment3.mdwn @@ -24,7 +24,21 @@ 8. Recall our proposed encoding for the numbers, called "Church's encoding". As we explained last week, it's similar to our proposed encoding of lists in terms of their folds. In last week's homework, you defined `succ` for numbers so encoded. Can you now define `pred` in the Lambca Calculus? Let `pred 0` result in whatever `err` is bound to. This is challenging. For some time theorists weren't sure it could be done. (Here is [some interesting commentary](http://okmij.org/ftp/Computation/lambda-calc.html#predecessor).) However, in this week's notes we examined one strategy for defining `tail` for our chosen encodings of lists, and given the similarities we explained between lists and numbers, perhaps that will give you some guidance in defining `pred` for numbers. -9. Define `leq` for numbers (that is, ≤) in the Lambda Calculus. +9. Define `leq` for numbers (that is, ≤) in the Lambda Calculus. Here is the expected behavior, +where `one` abbreviates `succ zero`, and `two` abbreviates `succ (succ zero)`. + + leq zero zero ~~> true + leq zero one ~~> true + leq zero two ~~> true + leq one zero ~~> false + leq one one ~~> true + leq one two ~~> true + leq two zero ~~> false + leq two one ~~> false + leq two two ~~> true + ... + + You'll need to make use of the predecessor function, but it's not essential to understanding this problem that you have successfully implemented it yet. You can treat it as a black box. ## Combinatorial Logic @@ -53,3 +67,21 @@ Using the mapping specified in this week's notes, translate the following lambda 23. For each of the above translations, how many `I`s are there? Give a rule for describing what each `I` corresponds to in the original lambda term. + +More Lambda Practice +-------------------- + +Reduce to beta-normal forms: + +
    +
  1. `(\x. x (\y. y x)) (v w)` +
  2. `(\x. x (\x. y x)) (v w)` +
  3. `(\x. x (\y. y x)) (v x)` +
  4. `(\x. x (\y. y x)) (v y)` + +
  5. `(\x y. x y y) u v` +
  6. `(\x y. y x) (u v) z w` +
  7. `(\x y. x) (\u u)` +
  8. `(\x y z. x z (y z)) (\u v. u)` +
+ diff --git a/randj.jpg b/images/randj.jpg similarity index 100% rename from randj.jpg rename to images/randj.jpg diff --git a/rosetta1.mdwn b/rosetta1.mdwn index 0a09c7c9..e3534511 100644 --- a/rosetta1.mdwn +++ b/rosetta1.mdwn @@ -2,7 +2,7 @@ ## Can you summarize the differences between your made-up language and Scheme, OCaml, and Haskell? ## -The made-up language we wet our toes in in week 1 is called Kapulet. (I'll tell you [the story behind its name](/randj.jpg) sometime.) The purpose of starting with this language is that it represents something of a center of gravity between Scheme, OCaml, and Haskell, and also lacks many of their idiosyncratic warts. One downside is that it's not yet implemented in a form that you can run on your computers. So for now, if you want to try out your code on a real mechanical evaluator, you'll need to use one of the other languages. +The made-up language we wet our toes in in week 1 is called Kapulet. (I'll tell you [the story behind its name](/images/randj.jpg) sometime.) The purpose of starting with this language is that it represents something of a center of gravity between Scheme, OCaml, and Haskell, and also lacks many of their idiosyncratic warts. One downside is that it's not yet implemented in a form that you can run on your computers. So for now, if you want to try out your code on a real mechanical evaluator, you'll need to use one of the other languages. Also, if you want to read code written outside this seminar, or have others read your code, for these reasons too you'll need to make the shift over to one of the established languages.