At the top right and at the bottom right of the present page, there is a clickable word, “index”, to access the index of the current version of the lecture notes. Click on it and then peruse the index, making sure that its entries make sense to you (otherwise, click on them to check them out).
The lecture notes start with updates (Chapter Lecture Notes for Intro to CS, updates). Make sure to check them out regularly, as they reflect the development of the lecture.
Briefly explain, in your own words, the concept of commuting diagram, as presented in the postlude of Chapter Towards OCaml.
For one more example (which could be connected to Exercise 08.i):
For your general culture, check out the author’s tribute to Peter Landin.
A question about the design of OCaml:
Justify this choice.
Hint: contemplate the APP typing rule.
Richard Feynman: I believe that has some significance for [y]our problem.Mimer: Professor Feynman! Thanks for stopping by!Halcyon (whispering to Vigfus): Is he joking? Mr. Feynman I mean.Vigfus (whispering back): I am not sure.Mimer: Huh, by the by, would you mind autographing my copy of your book?
Consider the following definition:
let length_of_string_self_concatenation s =
String.length (s ^ s) = 2 * String.length s;;
What is the result of applying length_of_string_concatenation to any string?
Justify your answer.
The answer is true, always, because concatenating a string to itself yields a string which is twice as long.
The computation carried out by length_of_string_self_concatenation can be depicted with the following commuting diagram:
Consider the following definition:
let length_of_string_concatenation s1 s2 =
String.length (s1 ^ s2) = String.length s1 + String.length s2;;
What is the result of applying length_of_string_concatenation to any two strings?
Justify your answer.
Déjà vu, anyone?
Strange.
Let us revisit the FUN, APP, and LET typing rules:
FUN | G, (x1 : t1) |- e2 : t2 | |
G |- fun x1 -> e2 : t1 -> t2 |
APP | G |- e0 : t1 -> t2 | G |- e1 : t1 | |
G |- e0 e1 : t2 |
LET | G |- e1 : t1 | (x1 : t1), G |- e2 : t2 | |
G |- let x1 = e1 in e2 : t2 |
For the sake of this exercise, let us assume that for any name x1 and for any expression e1 and e2, a let-expression such as let x1 = e1 in e2 is syntactic sugar for (fun x1 -> e2) e1, a principle of correspondence due to Peter Landin. Is this syntactic sugar compatible with the typing rules just above? In other words, can the LET typing rule be derived out of the FUN and APP typing rules?