Weeknotes for 3 April 2026 (week 13) [2026-W13]
- April 4, 2026
- Brent A. Yorgey
Introduction forms for immutable arrays [00GM]
- May 3, 2026
- Brent A. Yorgey
After mentioning it in last week's weeknotes, I got some great feedback from Verity on an introduction form for immutable arrays. (Again, the biggest constraint here is that we don't want to use lists: Swarm does have lists, but not built-in in a primitive way. Using lists requires you to first unlock algebraic data types as well as recursive types, and you should be able to unlock and use arrays independently.)
After a bit of back and forth, the current best idea is
(Int -> a) -> b -> (b -> Unit + Int * (a -> (a * b))) -> Array a
- The first argument specifies the starting value at any index.
- The second argument is a seed value for the unfold.
- I like to think of the third argument as a protocol for communication between the array constructor and the user, specifying the process for a sort of imperative unfold.
- The array constructor begins by announcing the current seed value of type
b. - The user gets to choose whether to stop, or to continue by specifying an index.
- The array constructor provides the value of type
acurrently at that index. - The user then gets to provide a new value of type
a, and a new seed.
- The array constructor begins by announcing the current seed value of type
Draft blog post on zero/empty set/void type/monoids etc.
- April 4, 2026
- Brent A. Yorgey
Inspired by a conversation on Mastodon, I've started drafting a blog post on the connections between things like \forall with an empty domain, functions out of empty types, sum/product/and/or of an empty list, etc.. None of this will be at all surprising to experienced Haskell programmers or type theorists, but I hope it may be interesting for some who are just learning.
As these things always happen, when I started expanding my outline into prose, I found that the very first bullet point in the outline expanded into enough material for an entire blog post. So it may just be very long, or I may split it up into multiple posts... we'll see!
Teaching induction
- April 4, 2026
- Brent A. Yorgey
I had a lot of fun this week teaching my Discrete Math students about induction principles for natural numbers.
On Wednesday I went over a strong induction principle. When I teach them, I usually state it like P(0) \land (\forall k. (\forall j \leq k. P(j)) \to P(k+1)) \to \forall n. P(n) I find a formulation without an explicit base case more elegant, but I don't think I am brave enough to teach it this way: (\forall k. (\forall j < k. P(j)) \to P(k)) \to \forall n. P(n) I think they would be completely confused by the apparent lack of a base case. Of course, the base case is still there, in the sense that you have to at the very least prove P(0) with no assumptions, since \forall j < 0. P(j) is trivial. But you would essentially have to almost always start by doing a case split on whether n is 0 anyway, so I feel like I might as well present it in a form with P(0) already split out separately. But I would be interested to hear about how others teach this. Of course, in some sense it doesn't matter since the two principles are logically equivalent, but I think it matters in a pedagogical sense.
As the crowning example, I proved that every natural number can be written as a sum of distinct powers of two... and then showed them that our induction proof is actually a recursive program for calculating the binary expansion of any natural number, by coding it in Disco:
binary : N -> Set(N)
binary(0) = {}
binary(2k) = {e+1 | e in binary(k)}
binary(2k+1) = {0} union {e+1 | e in binary(k)}
I definitely enjoyed seeing several of them get head-exploding expressions on their faces when they realized the correspondence between invoking the induction hypothesis and making a recursive function call.
A polynomial testing principle
- April 4, 2026
- Brent A. Yorgey
I've had Conor McBride's paper A polynomial testing principle on my reading list for a while, and this week I finally got around to reading through it carefully, typing up all the Agda code myself and trying to fill in as much of it as I could before peeking. I now have some much better ideas about how to encode things nicely in Agda. The topic of the paper was also really fun: I was definitely familiar with the idea that two degree-n polynomials must be equal if they agree at n+1 points, but I would not have guessed that this can be proved in a few hundred lines of Agda. I also enjoyed how it hinged on the forward difference and summation operators, old friends of mine from reading Concrete Mathematics when I was in undergrad.
Piano corner
- April 4, 2026
- Brent A. Yorgey
For the past few weeks I have been working on Chopin's 1st piano concerto. This is not the first time I've worked on it, but I haven't in a while. I have long dreamed of performing it someday. I always figured this was essentially a pipe dream, but after recently seeing a video of Olga Scheps playing it with a small chamber orchestra, I have a bit more hope that it might be possible! I didn't even realize there was an arrangement for chamber orchestra. Of course there are arrangements for two pianos as well, though that idea doesn't excite me as much.