cs3110 / textbook

The CS 3110 Textbook, "OCaml Programming: Correct + Efficient + Beautiful"
Other
720 stars 132 forks source link

Fixes and improvements #132

Closed cionx closed 9 months ago

cionx commented 1 year ago

This pull request is a collection of various minor things that I noticed while working through the textbook. I’ve organized these changes into eight commits to make this pull request easier to review. I can reorganize/rebase the changes in a different way, or replace this pull request by multiple smaller ones, if this is more helpful.

The commits are organized as follows:

  1. Fix math formulas mainly exists to fix an error in ds/amortized, where the sum $∑_{i=1}^k 200i$ is wrongly evaluated as $200k ⋅ 200 (k+1) / 2$.

  2. Consistent choice of operations for Core Ocaml: The running example of Core OCaml in Chapter 9 (interpreters) is currently defined with the following binary operations:

    bop ::= + | * | < | =

    But for the small-step relation and the environment model, only rules for + are given. (For the big-step relation, an arbitrary placeholder bop is used.) Looking through the rest of the chapter, it also turns out that the operations that we actually use are +, *, <=, -.

  3. Fix code examples and code formatting should be pretty self-explanatory.

  4. Fix typos, punctuation and single words is similarly self-explanatory. This commit contains only small changes, and at most adds, removes or replaces a word.

  5. Add commas: I put these changes into their own commit, since I’m not entirely sure about them.

  6. More consistent spelling and word usage: Certain words don’t have a clear spelling, e.g., “nonempty” vs “non-empty”. There can similarly be different choices of capitalization, e.g., “Core Ocaml” vs “core Ocaml”. For some of these terms, I looked at which form is most used throughout the textbook (by searching for all instances with grep), and then adjusted the other ones. An explicit list of changes can be found in the commit description.

  7. Minor improvements contains four changes that didn’t fit anywhere else, and that are arguably not fixes:

    • Following the usual rules of mathematical typography, “iff” is spelled out as “if and only if” in the main text. (It remains unchanged in code comments.)
    • Exercise “product test” is as follows:
      Unit test the function `product` that you wrote in an exercise above.

      But there is no previous function named product. Instead, the above formulation refers to the unnamed function in the exercise “product”. We add the function name to this previous exercise.

    • In the exercise “normalize” we introduce the variable $x$ before it is used.
    • We replace the one instance of “ourself” in the text by “ourselves”. (I’m not sure if this counts as a typo, but it is at least inconsistent with the rest of the textbook, which exclusively uses “ourselves”.)
  8. Improve LaTeX: For the separator line in set-definitions one should use \mid. Some places where missing a \mathrel. The ellipsis in a sum $x_1 + \dotsb + x_n$ is typeset with \dotsb (or worst case \cdots), but not with \ldots, as this doesn’t align the ellipsis correctly.

clarksmr commented 1 year ago

We're on spring break this week, but I'll take a look later when we are back.

clarksmr commented 9 months ago

Thank you @cionx for all these improvements, and apologies that it took so long for me to review and merge them. (I wasn't teaching the course during calendar year 2023, but I'm back to it now in 2024.)