The Computing Series

Exercises

Level 1 — Understand

  1. Classify each of the following as: (a) a statement, (b) an open statement / predicate, (c) not a statement. Explain your reasoning.

    • “The number 17 is divisible by 3.”
    • “Delete all rows where status = ‘expired’.”
    • “n is a power of 2.”
    • “Is the server reachable?”
    • “The empty string is falsy in Python.”
  2. What is the difference between a statement and an open statement? Give a programming example of each.

  3. State the Law of Excluded Middle. Name one common computing context where it does not hold, and explain why that context deviates from classical logic.

Level 2 — Apply

Consider this Python function:

def should_retry(attempt: int, error_code: int, is_idempotent: bool) -> bool:
    return attempt < 3 and error_code >= 500 and is_idempotent
  1. Identify the three atomic statements that compose the return expression.

  2. The function is called as should_retry(2, 503, True). Evaluate each atomic statement and the compound statement. Show your work.

  3. A new requirement arrives: “also retry on error code 429, but only if the attempt count is less than 5.” Rewrite the function. Identify what new atomic statements you introduced.

Level 3 — Design

A monitoring system stores the result of health checks as boolean variables: db_healthy, cache_healthy, api_healthy. These are evaluated once per minute and cached.

  1. Identify at least two ways the boolean storage model creates contract violations (FM8).

  2. Propose a design that preserves the simplicity of boolean evaluation at the decision point (the if statement) while making the temporal assumptions explicit. Name the tradeoff you are making (AT3).

  3. A teammate proposes replacing the three booleans with a single SystemHealth enum with values HEALTHY, DEGRADED, PARTIAL, UNHEALTHY. What does this solve? What does it cost? Name the tradeoff explicitly using AT framework notation.

Read in the book →