The Metaphysics of Speed Limits

I’m teaching a first-year programming course this fall. It’s a new online-native offering of an existing course, which I’ve been developing over the past couple of years (I hope to write more about this later).

Early in the course I introduce Boolean values and conditional evaluation (we use the language Racket in this course, and teach the special form cond here; other languages might use an if statement). As a case study of using cond, I explore speeding fines. Here’s the problem setup:

Worked Example: Speeding Fines

If you’re caught driving over the speed limit on Ontario highways, you might be punished with a fine. The precise amount of the fine depends on how fast you were driving. As of 2019, the penalty structure was as follows:

Amount by which you exceeded the speed limit Amount you pay
Less than 20 km/h $3.00 per km/h over the speed limit
At least 20 km/h but less than 30 km/h $4.50 per km/h over the speed limit
At least 30 km/h but less than 50 km/h $7.00 per km/h over the speed limit
At least 50 km/h $9.75 per km/h over the speed limit.

(Highway Traffic Act, 1990)

Let’s turn this into a function speeding-fine that consumes a speed in km/h and produces the corresponding fine.

The lesson goes on to present the solution, which looks like this:

(define (speeding-fine speed)
  (cond
    [(< speed 100) 0]
    [(and (>= speed 100) (< speed 120)) (* 3.00 (- speed 100))]
    [(and (>= speed 120) (< speed 130)) (* 4.50 (- speed 100))]
    [(and (>= speed 130) (< speed 150)) (* 7.00 (- speed 100))]
    [(>= speed 150) (* 9.75 (- speed 100))]))

If Racket isn’t your cup of tea, don’t worry about it too much. The important part of the function definition is the line [(< speed 100) 0], which translates to “if your speed was less than 100 km/h, you pay a fine of zero dollars”.

On the discussion boards, a student made this observation in response: 

It’s just a technicality since the math works out either way, but the first condition should be [(<= speed 100) 0] rather than [(< speed 100) 0] because there is no fine for driving exactly at the speed limit. All the subsequent iterations of the example have the same issue.

In other words, driving at precisely 100 km/h should count as “not speeding”, whereas I counted it as “speeding” (by omitting it from the first condition). The choice of < vs. <= doesn’t affect the result of the computation, but there’s a philosophical question here. What do you think? Did I make a mistake?

In fact, I thought about this quite a bit when writing this lesson, so I had a comically long answer for the student. I created this post to share that response. (I was particularly pleased to be able to incorporate recent current events by suddenly pivoting to an unexpected connection. It’s a rhetorical device that I definitely borrowed from the blog of my old friend Eric Lippert.)


 

Hi, author of the course here. I’m delighted that you raised this point. I went back and forth several times over the choice of < vs. <= in that example. I think it’s actually a very subtle question, and I could probably write a 5000-word essay about it. I won’t! But let me try to explain my choice.

Note to students: this is beyond anything you need to care about. As the poster notes, this is a technicality, because it doesn’t affect the behaviour of the function (why not?). So feel free to ignore this and complete Module 02 without thinking about it.

The main reason I went with < is for consistency with the other conditions. The law definitely says, e.g., “less than 20 km/h” to define a tier for the fine structure, so we know we’ll need a < in the second and all subsequent cases. I thought the code would look simpler with a < for the speed limit too, and I had the luxury of making that choice because it doesn’t matter mathematically (whereas it does matter at the higher tiers).

But there’s a subtler mathematical point here. What is speed? In particular, is it a continuous or discrete quantity? There’s only one person qualified to answer this question: the rapper Kanye West.

Earlier this year, Yeezy announced that he was running for President of the US. It was only later that he realized that you can’t just say that and have it be true—there are forms to fill out, signatures to gather, etc. You have to get on the ballot in every state. He tried to get on the ballot in Wisconsin, which had a filing deadline of 5:00pm on August 4th. He submitted the forms 14 seconds after the stroke of 5:00pm, and was told that the deadline had passed. Predictably, his lawyers sent a 23-page complaint to the election commission, arguing that the entire minute of 5:00pm technically counts as On Time, because the law doesn’t talk about seconds. (See this article for more.)

So, what is a deadline? Is it a finite interval of time, like “the minute of 5:00pm”? Or is it an instantaneous transition from “on time” to “late”? And what’s a speed limit? Is it a continuous range of speeds, say [100,101) km/h, or is it the infinitesimal transition from less than 100 to more than 100? If it’s instantaneous, what would it mean to file your paperwork at exactly 5:00pm, or to travel at exactly 100 km/h? The, uh, good news is that it’s physically impossible to do either; or rather, the laws of physics don’t permit us to measure time or speed accurately enough to know that you’re doing that. Given enough digits of precision, every clock and radar gun will put you either before the threshold or after it, never on it.

I doubt any of this has ever been tested in court (but I would love to see that happen). The real world just isn’t set up to make these kinds of distinctions, and thank goodness. We avoid these transitional areas—you might get pulled over for going 10 km/h over the speed limit, but probably not for going 0.1 km/h over the speed limit (I hope you can afford the $0.30 ticket). And so, from a surprisingly deep philosophical perspective, I didn’t sweat the difference between < and <= too much in writing the function, because it can’t possibly matter.

By the way, watch for this point to arise again in the course, in Lesson 04.7. There, I make a metaphor with Racket sports, and the question of whether “on the line” is in or out.

Have a good weekend!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.