Exercises for Week 05

Exercise 00

  1. 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).
  2. 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.
  3. Do take the time to peruse the lecture notes of this week and to reproduce their OCaml content.
  4. What is the computational content of a paradox? Revisit Exercise 20 in Week 01.
  5. In the chapter about the factorial function, the factorial function refers to itself. That sounds paradoxical, and yet applying it on a non-negative integer terminates. Why is that?

Mandatory exercises

  • Exercise 00: perusing the index and checking the updates
  • Exercise 01: some food for thought about basic computational arithmetic
  • Exercise 02: mapping a string of letters from lowercase to uppercase and vice-versa
  • Exercise 06: implementing a polymorphic unparser for quadruples
  • Exercise 07: comparing and contrasting two proof trees
  • Exercise 11: implementing a predicate to determine whether a given non-negative integer is odd
  • Exercise 12: testing the unit-test function for nat_of_digits
  • Exercise 13: explaining nat_of_digit
  • Exercise 14: implementing the base case of nat_of_digits
  • Exercise 15: implementing the induction-step of nat_of_digits
  • Exercise 16: debugging an implementation of the power function

Exercise 16

The accompanying .ml file contains a bug, and your task is to fix this bug.

To this end, load this file a few times in OCaml, as in:

# #use "week-05_power.ml";;
...
#

until the bug becomes apparent (i.e., when an assertion fails to hold).

Then figure it out and fix it.

Hint: redefine the silent flag at the beginning of the file to enable the displaying of error messages.

Subsidiary request: analyze the said error messages, their structure, and how they come about.

Resources

Version

Completed [13 Feb 2022]

Nearly completed [13 Feb 2022]

Created [12 Feb 2022]

Table Of Contents

Previous topic

Polynomials revisited

Next topic

Lecture Notes, Week 06