The Universe of Discourse


Fri, 29 Nov 2024

A complex bug with a ⸢simple⸣ fix

Last month I did a fairly complex piece of systems programming that worked surprisingly well. But it had one big bug that took me a day to track down.

One reason I find the bug interesting is that it exemplifies the sort of challenges that come up in systems programming. The essence of systems programming is that your program is dealing with the state of a complex world, with many independent agents it can't control, all changing things around. Often one can write a program that puts down a wrench and then picks it up again without looking. In systems programming, the program may have to be prepared for the possibility that someone else has come along and moved the wrench.

The other reason the bug is interesting is that although it was a big bug, fixing it required only a tiny change. I often struggle to communicate to nonprogrammers just how finicky and fussy programming is. Nonprogrammers, even people who have taken a programming class or two, are used to being harassed by crappy UIs (or by the compiler) about missing punctuation marks and trivially malformed inputs, and they think they understand how fussy programming is. But they usually do not. The issue is much deeper, and I think this is a great example that will help communicate the point.

The job of my program, called sync-spam, was to move several weeks of accumulated email from system S to system T. Each message was probably spam, but its owner had not confirmed that yet, and the message was not yet old enough to be thrown away without confirmation.

The probably-spam messages were stored on system S in a directory hierarchy with paths like this:

    /spam/2024-10-18/…

where 2024-10-18 was the date the message had been received. Every message system S had received on October 18 was somewhere under /spam/2024-10-18.

One directory, the one for the current date, was "active", and new messages were constantly being written to it by some other programs not directly related to mine. The directories for the older dates never changed. Once sync-spam had dealt with the backlog of old messages, it would continue to run, checking periodically for new messages in the active directory.

The sync-spam program had a database that recorded, for each message, whether it had successfully sent that message from S to T, so that it wouldn't try to send the same message again.

The program worked like this:

  • Repeat forever:
    1. Scan the top-level spam directory for the available dates
    2. For each date D:
      1. Scan the directory for D and find the messages in it. Add to the database any messages not already recorded there.
      2. Query the database for the list of messages for date D that have not yet been sent to T
      3. For each such message:
        1. Attempt to send the message
        2. If the attempt was successful, record that in the database
    3. Wait some appropriate amount of time and continue.

Okay, very good. The program would first attempt to deal with all the accumulated messages in roughly chronological order, processing the large backlog. Let's say that on November 1 it got around to scanning the active 2024-11-01 directory for the first time. There are many messages, and scanning takes several minutes, so by the time it finishes scanning, some new messages will be in the active directory that it hasn't seen. That's okay. The program will attempt to send the messages that it has seen. The next time it comes around to 2024-11-01 it will re-scan the directory and find the new messages that have appeared since the last time around.

But scanning a date directory takes several minutes, so we would prefer not to do it if we don't have to. Since only the active directory ever changes, if the program is running on November 1, it can be sure that none of the directories from October will ever change again, so there is no point in its rescanning them. In fact, once we have located the messages in a date directory and recorded them in the database, there is no point in scanning it again unless it is the active directory, the one for today's date.

So sync-spam had an elaboration that made it much more efficient. It was able to put a mark on a date directory that meant "I have completely scanned this directory and I know it will not change again". The algorithm was just as I said above, except with these elaborations.

  • Repeat forever:
    1. Scan the top-level spam directory for the available dates
    2. For each date D:
        • If the directory for D is marked as having already been scanned, we already know exactly what messages are in it, since they are already recorded in the database.
        • Otherwise:
          1. Scan the directory for D and find the messages in it. Add to the database any messages not already recorded there.
          2. If D is not today's date, mark the directory for D as having been scanned completely, because we need not scan it again.
      1. Query the database for the list of messages for date D that have not yet been sent to T
      2. For each such message:
        1. Attempt to send the message
        2. If the attempt was successful, record that in the database
    3. Wait some appropriate amount of time and continue.

It's important to not mark the active directory as having been completely scanned, because new messages are continually being deposited into it until the end of the day.

I implemented this, we started it up, and it looked good. For several days it processed the backlog of unsent messages from September and October, and it successfully sent most of them. It eventually caught up to the active directory for the current date, 2024-11-01, scanned it, and sent most of the messages. Then it went back and started over again with the earliest date, attempting to send any messages that it hadn't sent the first time.

But a couple of days later, we noticed that something was wrong. Directories 2024-11-02 and 2024-11-03 had been created and were well-stocked with the messages that had been received on those dates. The program had found the directories for those dates and had marked them as having been scanned, but there were no messages from those dates in its database.

Now why do you suppose that is?

(Spoilers will follow the horizontal line.)

I investigate this in two ways. First, I made sync-spam's logging more detailed and looked at the results. While I was waiting for more logs to accumulate, I built a little tool that would generate a small, simulated spam directory on my local machine, and then I ran sync-spam against the simulated messages, to make sure it was doing what I expected.

In the end, though, neither of these led directly to my solving the problem; I just had a sudden inspiration. This is very unusual for me. Still, I probably wouldn't have had the sudden inspiration if the information from the logging and the debugging hadn't been percolating around my head. Fortune favors the prepared mind.


The problem was this: some other agent was creating the 2024-11-02 directory a bit prematurely, say at 11:55 PM on November 1.

Then sync-spam came along in the last minutes of November 1 and started its main loop. It scanned the spam directory for available dates, and found 2024-11-02. It processed the unsent messages from the directories for earlier dates, then looked at 2024-11-02 for the first time. And then, at around 11:58, as per above it would:

  1. Scan the directory for 2024-11-02 and find the messages in it. Add to the database any messages not already recorded there.

There weren't any yet, because it was still 11:58 on November 1.

  1. If 2024-11-02 is not today's date, mark the directory as having been scanned completely, because we need not scan it again.

Since the 2024-11-02 directory was not the one for today's date — it was still 11:58 on November 1 — sync-spam recorded that it had scanned that directory completely and need not scan it again.

Five minutes later, at 00:03 on November 2, there would be new messages in the 2024-11-02, which was now the active directory, but sync-spam wouldn't look for them, because it had already marked 2024-11-02 as having been scanned completely.

This complex problem in this large program was completely fixed by changing:

        if ($date ne $self->current_date) {
          $self->mark_this_date_fully_scanned($date_dir);
        }

to:

        if ($date lt $self->current_date) {
          $self->mark_this_date_fully_scanned($date_dir);
        }

(ne and lt are Perl-speak for "not equal to" and "less than".)

Many organizations have their own version of a certain legend, which tells how a famous person from the past was once called out of retirement to solve a technical problem that nobody else could understand. I first heard the General Electric version of the legend, in which Charles Proteus Steinmetz was called out of retirement to figure out why a large complex of electrical equipment was not working.

In the story, Steinmetz walked around the room, looking briefly at each of the large complicated machines. Then, without a word, he took a piece of chalk from his pocket, marked one of the panels, and departed. When the puzzled engineers removed that panel, they found a failed component, and when that component was replaced, the problem was solved.

Steinmetz's consulting bill for $10,000 arrived the following week. Shocked, the bean-counters replied that $10,000 seemed an exorbitant fee for making a single chalk mark, and, hoping to embarrass him into reducing the fee, asked him to itemize the bill.

Steinmetz returned the itemized bill:

One chalk mark $1.00
Knowing where to put it $9,999.00
TOTAL $10,000.00

This felt like one of those times. Any day when I can feel a connection with Charles Proteus Steinmetz is a good day.

This episode also makes me think of the following variation on an old joke:

A: Ask me what is the most difficult thing about systems programming.

B: Okay, what is the most difficult thing ab—

A: TIMING!


[Other articles in category /prog/bug] permanent link

Sat, 31 Aug 2024

Another corner of Pennsylvania

[ Previously: [1] [2] [3] ]

A couple of years back I wrote:

I live in southeastern Pennsylvania, so the Pennsylvania-New Jersey-Delaware triple point must be somewhere nearby. I sat up and got my phone so I could look at the map, and felt foolish.

Map of the
Pennsylvania-New Jersey-Delaware triple border, about a kilometer
offshore from Marcus Hook, PA, further described below.

As you can see, the triple point is in the middle of the Delaware River, as of course it must be; the entire border between Pennsylvania and New Jersey, all the hundreds of miles from its northernmost point (near Port Jervis) to its southernmost (shown above), runs right down the middle of the Delaware.

I briefly considered making a trip to get as close as possible, and photographing the point from land. That would not be too inconvenient. Nearby Marcus Hook is served by commuter rail. But Marcus Hook is not very attractive as a destination. Having been to Marcus Hook, it is hard for me to work up much enthusiasm for a return visit.

I was recently passing by Marcus Hook on the way back from Annapolis, so I thought what the heck, I'd stop in and see if I could get a look in the direction of the tripoint. As you can see from this screencap, I was at least standing in the right place, pointed in the right direction.

Screencap of
my phone's map app, showing the same part of the river as the map
above.  This one is marked with a blue dot (me) near the Marcus Hook
Industrial Complex, pointed towards the tripoint, also labeled.

I didn't quite see the tripoint itself because this buoyancy-operated aquatic transport was in the way. I don't mind, it was more interesting to look at than open water would have been.

Photo
of the Delaware river, taken from the Pennsylvania shore.  The near
bank is covered with pretty green and purple weeds.  Floating in the
river directly ahead is a pale green ship with a white superstructure,
the BW Messina

Thanks to the Wonders of the Internet, I have learned that this is an LPG tanker. Hydrocarbons from hundreds of miles away are delivered to the refinery in Marcus Hook via rail, road, and pipeline, and then shipped out on vessels like this one. Infrastructure fans should check it out.

I was pleased to find that Marcus Hook wasn't as dismal as I remembered, it's just a typical industrial small town. I thought maybe I should go back and look around some more. If you hoped I might have something more interesting or even profound to say here, sorry.

Oh, I know. Here, I took this picture in Annapolis:

A sandstone plinth with the Maryland state coat of arms carved in
bas-relief at the top. Under this are engraved words: ALBERT CABELL
RITCHIE / 2876 – 1936 / FOUR TIMES GOVERNOR OF MARYLAND / HE WHO IS
WORTHY OF HONOR DOES NOT DIE.

Perhaps he who is worthy of honor does not die. But fame is fleeting. Even if he who is worthy of honor does get a plinth, the grateful populace may not want to shell out for a statue.


[Other articles in category /misc] permanent link

Sat, 24 Aug 2024

Dancing bread

Marnanel Thurman reported the following item that they found in an 1875 book titled How to Entertain a Social Party:

To Make a Loaf of Bread Dance on the Table.

— Having a quill filled with quicksilver and stopped close, you secretly thrust it into a hot roll or loaf, which will put it in motion.

(Bottom of page 46.) No further explanation is given.

This may remind you of an episode from Huckleberry Finn:

Well, then I happened to think how they always put quicksilver in loaves of bread and float them off, because they always go right to the drownded carcass and stop there.

(Chapter 8.)

When I first read this I assumed it was a local Southern superstition, characteristic of that place and time. But it seems not! According to this article by Dan Rolph of the Historical Society of Pennsylvania, the belief was longstanding and widespread, lasting from at least 1767 to 1872, and appearing also in London and in Pennsylvania.

Details of the dancing bread trick are lacking. I guess the quicksilver stays inside the stopped-up quill. (Otherwise, there would be no need to “stop it close”.) Then perhaps on being heated by the bread, the quicksilver expands lengthwise as in a thermometer, and then… my imagination fails me.

The procedure for making drowned-body-finding bread is quite different. Rolph's sources all agree: you poke in your finger and scoop out a bit of the inside, pour the quicksilver into the cavity, and then plug up the hole. So there's no quill; the quicksilver is just sloshing around loose in there. Huckleberry Finn agrees:

I took out the plug and shook out the little dab of quicksilver…

Does anyone have more information about this? Does hot bread filled with mercury really dance on the table, and if so why? Is the supersition about bread finding drowned bodies related to this, or is it a coincidence?

Also, what song did the sirens sing, and by what name was Achilles called when he hid among women?


[Other articles in category /misc] permanent link

Thu, 22 Aug 2024

XKCD game theory question

Six-panel cartoon from XKCD.
Each panel gives a one-question mathematics ‘final exam’ from
a different level of education from ‘kindergarten’ to 
‘postgraduate math’.  This article concerns the fifth, which says
“Game Theory Final Exam: Q. Write down 10 more than the average of
the class’s answers.  A. (blank).”

(Source: XKCD “Exam numbers”.)

This post is about the bottom center panel, “Game Theory final exam”.

I don't know much about game theory and I haven't seen any other discussion of this question. But I have a strategy I think is plausible and I'm somewhat pleased with.

(I assume that answers to the exam question must be real numbers — not !!\infty!! — and that “average” here is short for 'arithmetic mean'.)

First, I believe the other players and I must find a way to agree on what the average will be, or else we are all doomed. We can't communicate, so we should choose a Schelling point and hope that everyone else chooses the same one. Fortunately, there is only one distinguished choice: zero. So I will try to make the average zero and I will hope that others are trying to do the same.

If we succeed in doing this, any winning entry will therefore be !!10!!. Not all !!n!! players can win because the average must be !!0!!. But !!n-1!! can win, if the one other player writes !!-10(n-1)!!. So my job is to decide whether I will be the loser. I should select a random integer between !!0!! and !!n-1!!. If it is zero, I have drawn a short straw, and will write !!-10(n-1)!!. otherwise I write !!10!!.

(The straw-drawing analogy is perhaps misleading. Normally, exactly one straw is short. Here, any or all of the straws might be short.)

If everyone follows this strategy, then I will win if exactly one person draws a short straw and if that one person isn't me. The former has a probability that rapidly approaches !!\frac1e\approx 36.8\%!! as !!n!! increases, and the latter is !!\frac{n-1}n!!. In an !!n!!-person class, the probability of my winning is $$\left(\frac{n-1}n\right)^n$$ which is already better than !!\frac13!! when !!n= 6!!, and it increases slowly toward !!36.8\%!! after that.

Some miscellaneous thoughts:

  1. The whole thing depends on my idea that everyone will agree on !!0!! as a Schelling point. Is that even how Schelling points work? Maybe I don't understand Schelling points.

  2. I like that the probability !!\frac1e!! appears. It's surprising how often this comes up, often when multiple agents try to coordinate without communicating. For example, in ALOHAnet a number of ground stations independently try to send packets to a single satellite transceiver, but if more than one tries to send a packet at a particular time, the packets are garbled and must be retransmitted. At most !!\frac1e!! of the available bandwidth can be used, the rest being lost to packet collisions.

  3. The first strategy I thought of was plausible but worse: flip a coin, and write down !!10!! if it is heads and !!-10!! if it is tails. With this strategy I win if exactly !!\frac n2!! of the class flips heads and if I do too. The probability of this happening is only $$\frac{n\choose n/2}{2^n}\cdot \frac12 \approx \frac1{\sqrt{2\pi n}}.$$ Unlike the other strategy, this decreases to zero as !!n!! increases, and in no case is it better than the first strategy. It also fails badly if the class contains an odd number of people.

    Thanks to Brian Lee for figuring out the asymptotic value of !!4^{-n}\binom{2n}{n}!! so I didn't have to.

  4. Just because this was the best strategy I could think of in no way means that it is the best there is. There might have been something much smarter that I did not think of, and if there is then my strategy will sabotage everyone else.

    Game theorists do think of all sorts of weird strategies that you wouldn't expect could exist. I wrote an article about one a few years back.

  5. Going in the other direction, even if !!n-1!! of the smartest people all agree on the smartest possible strategy, if the !!n!!th person is Leeroy Jenkins, he is going to ruin it for everyone.

  6. If I were grading this exam, I might give full marks to anyone who wrote down either !!10!! or !!-10(n-1)!!, even if the average came out to something else.

  7. For a similar and also interesting but less slippery question, see Wikipedia's article on Guess ⅔ of the average. Much of the discussion there is directly relevant. For example, “For Nash equilibrium to be played, players would need to assume both that everyone else is rational and that there is common knowledge of rationality. However, this is a strong assumption.” LEEROY JENKINS!!

  8. People sometimes suggest that the real Schelling point is for everyone to write !!\infty!!. (Or perhaps !!-\infty!!.)

    Feh.

  9. If the class knows ahead of time what the question will be, the strategy becomes a great deal more complicated! Say there are six students. At most five of them can win. So they get together and draw straws to see who will make a sacrifice for the common good. Vidkun gets the (unique) short straw, and agrees to write !!-50!!. The others accordingly write !!10!!, but they discover that instead of !!-50!!, Vidkun has written !!22!! and is the only person to have guessed correctly.

    I would be interested to learn if there is a playable Nash equilibrium under these circumstances. It might be that the optimal strategy is for everyone to play as if they didn't know what the question was beforehand!

    Suppose the players agree to follow the strategy I outlined, each rolling a die and writing !!-50!! with probability !!\frac16!!, and !!10!! otherwise. And suppose that although the others do this, Vidkun skips the die roll and unconditionally writes !!10!!. As before, !!n-1!! players (including Vidkun) win if exactly one of them rolls zero. Vidkun's chance of winning increases. Intuitively, the other players' chances of winning ought to decrease. But by how much? I think I keep messing up the calculation because I keep getting zero. If this were actually correct, it would be a fascinating paradox!


[Other articles in category /math] permanent link

Wed, 21 Aug 2024

I DON'T KNOW

If you're an annoying know-it-all like me, I suggest that you try playing the following game when you attend a conference or a user group meetup or even a work meeting. The game is:

If someone asks you a question, and you say “I don't know”, you score a point.

That's it. That's the game. “I don't know” doesn't have to be perfectly truthful, only approximately truthful.

I forgot, there is one other rule:

If you follow up with something like “But if I had to guess…” you lose your point again.


[Other articles in category /brain] permanent link

Wed, 14 Aug 2024

Poor Richard's Almanack

Benjamin Franklin wrote and published Poor Richard's Almanack annually from 1732 to 1758. Paper was expensive and printing difficult and time-consuming. The type would be inked, the sheet of paper laid on the press, the apprentices would press the sheet, by turning a big screw. Then the sheet was removed and hung up to dry. Then you can do another printing of the same page. Do this ten thousand times and you have ten thousand prints of a sheet. Do it ten thousand more to print a second sheet. Then print the second side of the first sheet ten thousand times and print the second side of the second sheet ten thousand times. Fold 20,000 sheets into eighths, cut and bind them into 10,000 thirty-two page pamphlets and you have your Almanacks.

As a youth, Franklin was apprenticed to his brother James, also a printer, in Boston. Franklin liked the work, but James drank and beat him, so he ran away to Philadelphia. When James died, Benjamin sent his widowed sister-in-law Ann five hundred copies of the Almanack to sell. When I first heard that I thought it was a mean present but I was being a twenty-first-century fool. The pressing of five hundred almanacks is no small feat of toil. Ann would have been able to sell those Almanacks in her print shop for fivepence each, or ₤10 8s. 4d. That was a lot of money in 1735.

In 1748 Franklin increased the size and the price. Here's a typical page from the 1748 Almanack:

detailed description in the article

Wow, there's a lot of stuff going on there. Here's a smaller excerpt, this time from November 1753:

The leftmost column is the day of the month, and then the next column is the day of the week, with 2–7 being Monday through Saturday. Sunday is denoted with a letter “G”. I thought this was G for God, but I see that in 1748 Franklin used “C” and in 1752 he used “A”, so I don't know.

The third column combines a weather forecast and a calendar. The weather forecast is in italic type, over toward the right: “Clouds and threatens cold rains and snow” in the early part of the month. Sounds like November in Philadelphia. The roman type gives important days. For example, November 1 is All Saints Day and November 5 is the anniversary of the Gunpowder Plot. November 10 is given as the birthday of King George II, then still the King of Great Britain.

The Sundays are marked with some description in the Christian liturgical calendar. For example, “20 past Trin.” means it's the start of the 20th week past Trinity Sunday.

This column also has notations like “Days dec. 4 32” and “Days dec. 5 h.” that I haven't been able to figure out. Something about the decreasing length of the day in November maybe? [ Addendum: Yes. See below. ] The notation on November 6 says “Day 10 10 long” which is consistent with the sunrise and sunset times Franklin gives for that day. The fourth and fifth columns, labeled “☉ ris” and “☉ set” are the times of sunrise and sunset, 6:55 (AM) and 5:05 (PM) respectively for November 6, ten hours and ten minutes apart as Franklin says.

“☽ pl.” is the position of the moon in the sky. (I guess “pl.” is short for “place”.) The sky is divided into twelve “houses” of 30 degrees each, and when it says that the “☽ pl.” on November 6 is “♓ 25” I think it means the moon is !!\frac{25}{30}!! of the way along in the house of Pisces on its way to the house of Aries ♈. If you look at the January 1748 page above you can see the moon making its way through the whole sky in 29 days, as it does.

The last column, “Aspects, &c.” contains more astronomy. “♂ rise 6 13” means that Mars will rise at 6:13 that day. (But in the morning or the evening?) ⚹♃♀ on the 12th says that Jupiter is in sextile aspect to Venus, which means that they are in the sky 60 degrees apart. Similarly □☉♃ means that the Sun and Jupiter are in Square aspect, 90 degrees apart in the sky.

Also mixed into that last column, taking up the otherwise empty space, are the famous wise sayings of Poor Richard. Here we see:

Serving God is Doing Good to Man,
but Praying is thought an easier Service,
and therefore more generally chosen
.

Back on the January page you can see one of the more famous ones, Lost Time is never found again.

Franklin published an Almanack in 1752, the year that the British Calendar Act of 1751 updated the calendar from Julian to Gregorian reckoning. To bring the calendar into line with Gregorian, eleven days were dropped from September that year. I wondered what Franklin's calendar looked like that month. Here it is with the eleven days clearly missing:

The leftmost day-of-the-month column skips right from September 2 to September 14, as the law required. On this copy someone has added the old dates in the margin. Notice that St. Michael's Day, which would have been on Friday September 18th in the old calendar, has been moved up to September 29th. In most years Poor Richard's Almanack featured an essay by Poor Richard, little poems, and other reference material. The 1752 Almanack omitted most of this so that Franklin could use the space to instead reprint the entire text of the Calendar Act.

This page also commemorates the Great Fire of London, which began September 2, 1666.

Wikipedia tells me that Franklin may have gotten the King's birthday wrong. Franklin says November 10, but Wikipedia says November 9, and:

Over the course of George's life, two calendars were used: the Old Style Julian calendar and the New Style Gregorian calendar. Before 1700, the two calendars were 10 days apart. Hanover switched from the Julian to the Gregorian calendar on 19 February (O.S.) / 1 March (N.S.) 1700. Great Britain switched on 3/14 September 1752. George was born on 30 October Old Style, which was 9 November New Style, but because the calendar shifted forward a further day in 1700, the date is occasionally miscalculated as 10 November.

Ugh, calendars.

I got these scans from a web site called The Rare Book Room, but I found their user interface very troublesome, so I have scraped all the images they had. You may find them at https://pic.blog.plover.com/calendar/poor-richards-almanack/archive/. I'm pretty sure the copyright has expired, so share and enjoy.

Addenda

Several people have pointed out that the mysterious letters G, C, A on Sundays are the so-called dominical letters, used in remembering the correspondence between days of the month and days of the week, and important in the determination of the dates of Easter and other moveable feasts.

Why Franklin included them in the Almanack is not clear to me, as one of the main purposes of the almanac itself is so that you do not have to remember or calculate those things, you can just look them up in the almanac.

Mikkel Paulson explained the 'days dec.' and 'days inc.' notations: they describe the length of the day, but reported relative to the length of the most recent solstice. For example, the November 1753 excerpt for November 2 says "Days dec. 4 32". Going by the times of sunrise and sunset on that day, the day was 10 hours 18 minutes long. Adding the 4 hours 32 minutes from the notation we have 14 hours 50 minutes, which is indeed the length of the day on the summer solstice in Philadelphia, or close to it.

Similarly the notation on November 14 says "Days dec. 5 h" for a day that is 9 hours 50 minutes between sunrise and sunset, five hours shorter than on the summer solstice, and the January 3 entry says "Days inc. 18 m." for a 9h 28m day which is 18 minutes longer than the 9h 10m day one would have on the winter solstice.


[Other articles in category /calendar] permanent link

Wed, 07 Aug 2024

Stuff I wanted to say to the historic district people but didn't

[ Thanks to John Wiersba for noticing that I forgot to publish this. ]

A few weeks ago I wrote a letter to my neighbors about why I thought it was a bad idea to oppose building more housing in our neighborhood.

I didn't write this paragraph:

In the past it has often happened that a group of wealthy landowners conspired to hold onto what they had and keep anyone else from sharing it. I don't think anyone has ever looked back and said “Yep, those people had the right idea.”

But I wanted to.

Also, I omitted a long and detailed fantasy about how local landlords will have to lower rents and fix up their properties because of competition pressure from new apartment buildings.

“I wanted to raise rents this year, but I couldn't because all the rich Penn students moved into that new luxury apartment building. ”

“It was hard to find tenants this year, and I found out it was because Joe up the street fixed up all his bathrooms. If I wanna stay in business I'm gonna have to fix up all my bathrooms too!”

I left out any expression of my idea that if we really want to stick it to those greedy landlords, we should hit them where it really hurts, by expanding the supply of housing and breaking their monopoly.

And I didn't cite the literature that says that even building expensive apartment buildings tends to lower everyone else's rent:

The supply of new market rate units triggers moving chains that quickly reach middle- and low-income neighborhoods and individuals. Thus, new market-rate construction loosens the housing market in middle- and low-income areas even in the short run. Market-rate supply is likely to improve affordability outside the sub-markets where new construction occurs and to benefit low-income people.

(City-wide effects of new housing supply: Evidence from moving chains)

And I didn't vent my rage about Philadelphia's recent cash grants to people waiting for federal housing subsidies, which is an almost direct transfer of cash from the public purse into the pockets of landlords.

Ugh, housing policy is so messed up.

(I did later go to the public meeting about it, and what a fucking fuckhole of fucked-up fuckery that was. Fuck.)


[Other articles in category /politics] permanent link

Tue, 06 Aug 2024

Look at what they tried to take from us

When I was a kid, the Beatles’ seminal 1966 album Revolver was 20% shorter. The original release was not a long album: 14 tracks, totaling 34:45. But the version I grew up with had 11 tracks, totaling only 27:31.

Three tracks, all by Lennon, were omitted by Capitol from the North American release because they had previously been released on Yesterday and Today:

Cover of
Revolver.  It is a collage by the Beatles’ friend Klaus Voormann. It
primarily features Voorman's pen drawings of the four Beatles’ heads.
Around these and also sitting in and tangled in the Beatles’ hair are
cutout photographs of people and faces, some of the Beatles
themselves, some of other people.  Harrison’s eyes and lips are also
collage cutouts, which is a bit creepy.

  1. “Taxman”
  2. “Eleanor Rigby”
  3. “I'm Only Sleeping”
  4. “Love You To”
  5. “Here, There and Everywhere”
  6. “Yellow Submarine”
  7. “She Said She Said”

  1. “Good Day Sunshine”
  2. “And Your Bird Can Sing”
  3. “For No One”
  4. “Doctor Robert”
  5. “I Want to Tell You”
  6. ”Got to Get You into My Life”
  7. “Tomorrow Never Knows”


In 1987, the album was rereleased, with the missing tracks restored. But until I was in college, I had not only never heard the three omitted tracks, I didn't even know they existed.

When I found out, I was apprehensive. I loved Revolver. What if I didn't like the ⸢new⸣ tracks? What if the new tracks changed the Revolver I loved into something else?

Nothing like this happened. The new tracks fit in seamlessly. Of course they did! The new Revolver was more Revolver than the old Revolver had been.

It took a little while before I was no longer startled when “For No One” wasn't followed by “I Want to Tell You”, but not too long. (It took me longer to get used to the absence of the horrible skip that was in our vinyl copy of “Strawberry Fields Forever”.) New Revolver was the same Revolver I had always loved, only 25% longer and considerably better.

Douglas Hofstadter once asked us to imagine that a previously unknown but certainly authentic Bach cantata has been discovered, hiding in a drawer or something, but that the eager concertgoers hearing it for the first time are horrified to discover that its main theme is identical with the first seven notes of “Rudolph the Red-Nosed Reindeer”. This was like that, without the horrid twist ending.

Revolver was released yesterday, August 5, in 1966.


[Other articles in category /music] permanent link

Mon, 05 Aug 2024

Everyday examples of morphisms with one-sided inverses

Like almost everyone except Alexander Grothendieck, I understand things better with examples. For instance, how do you explain that

$$(f\circ g)^{-1} = g^{-1} \circ f^{-1}?$$

Oh, that's easy. Let !!f!! be putting on your shoes and !!f^{-1}!! be taking off your shoes. And let !!g!! be putting on your socks and !!g^{-1}!! be taking off your socks.

Now !!f\circ g!! is putting on your socks and then your shoes. And !!g^{-1} \circ f^{-1}!! is taking off your shoes and then your socks. You can't !!f^{-1} \circ g^{-1}!!, that says to take your socks off before your shoes.

(I see a topologist jumping up and down in the back row, desperate to point out that the socks were never inside the shoes to begin with. Sit down please!)

Sometimes operations commute, but not in general. If you're teaching group theory to high school students and they find nonabelian operations strange, the shoes-and-socks example is an unrebuttable demonstration that not everything is abelian.

(Subtraction is not a good example here, because subtracting !!a!! and then !!b!! is the same as subtracting !!b!! and then !!a!!. When we say that subtraction isn't commutative, we're talking about something else.)

Anyway this weekend I was thinking about very very elementary category theory (the only kind I know) and about left and right inverses. An arrow !!f : A\to B!! has a left inverse !!g!! if

$$g\circ f = 1_A.$$

Example of this are easy. If !!f!! is putting on your shoes, then !!g!! is taking them off again. !!A!! is the state of shoelessness and !!B!! is the state of being shod. This !!f!! has a left inverse and no right inverse. You can't take the shoes off before you put them on.

But I wanted an example of an !!f!! with right inverse and no left inverse:

$$f\circ h = 1_B$$

and I was pretty pleased when I came up with one involving pouring the cream pitcher into your coffee, which has no left inverse that gets you back to black coffee. But you can ⸢unpour⸣ the cream if you do it before mixing it with the coffee: if you first put the cream back into the carton in the refrigerator, then the pouring does get you to black coffee.

But now I feel silly. There is a trivial theorem that if !!g!! is a left inverse of !!f!!, then !!f!! is a right inverse of !!g!!. So the shoe example will do for both. If !!f!! is putting on your shoes, then !!g!! is taking them off again. And just as !!f!! has a left inverse and no right inverse, because you can't take your shoes off before putting them on, !!g!! has a right inverse (!!f!!) and no left inverse, because you can't take your shoes off before putting them on.

This reminds me a little of the time I tried to construct an example to show that “is a blood relation of" is not a transitive relation. I had this very strange and elaborate example involving two sets of sisters-in-law. But the right example is that almost everyone is the blood relative of both of their parents, who nevertheless are not (usually) blood relations.


[Other articles in category /math] permanent link

Fri, 12 Jul 2024

Loki the comedian

Toph and I were discussing the story of Loki and Skaði, one of my favorites. (Previously.) The Æsir have killed Skaði's father, and owe her compensation. She has been sad since her father died, she says, and demands that the Æsir make her laugh. Loki rubs his hands together and says "Leave this to me!".

He takes a rope, ties one end to a goat's beard, and the other and to his scrotum. Hilarity ensues.

Skaði tries not to laugh. She fails.

Toph asked a question I had not thought of, but that has been in my head ever since: "Do you think it was an idea he thought up on the spur of the moment? Or was it a bit he had planned ahead of time?"

Wow, I don't know. Was Loki suddenly struck with brilliant inspiration? Or did he think 'Aha, I knew this idea would come in handy sooner or later!' They're both plausible, right?


[Other articles in category /misc] permanent link

Fri, 05 Jul 2024

A triviality about numbers that look like abbc

Looking at license plates the other day I noticed that if you have a four-digit number !!N!! with digits !!abbc!!, and !!a+c=b!!, then !!N!! will always be a multiple of !!37!!. For example, !!4773 = 37\cdot 129!! and !!1776 = 37\cdot 48!!.

Mathematically this is uninteresting. The proof is completely trivial. (Such a number is simply !!1110a +111c!!, and !!111=3\cdot 37!!.)

But I thought that if someone had pointed this out to me when I was eight or nine, I would have been very pleased. Perhaps if you have a mathematical eight- or nine-year-old in your life, they will be pleased if you share this with them.


[Other articles in category /math] permanent link

Wed, 03 Jul 2024

My reply to the people who want to designate my neighborhood a "historic district"

Last week I received a widely circulated email that began:

With tall apartment buildings being erected all around, we feel it is ever more important to preserve our community.

I sent this reply.


I have been a Spruce Hill homeowner for 16 years. I had to miss the June 26 meeting because I was out of the country. But I think the historic designation is a bad idea and I'd like to explain why.

In brief, our city has a housing shortage and a homelessness problem. There is only one way out of this terrible situation: build more housing. A "Historic District" designation is a direct attempt to prevent exactly that.

I understand why many homeowners might be in favor of it. Homeowners already own homes. We homeowners are the wealthy incumbents, trying to prevent our housing monopoly from being disrupted. If housing is scarce, our houses will be worth more money, at least in theory. But if more housing is built, the price for existing houses, which we own, won't increase so quickly. From an individual homeowner's point of view, this looks like "big apartment buildings could depress my property values."

But I think this is self-deceptive. Having a house in a city with a lot of homeless people, and one where essential workers can't afford to live, will also depress property values. It's not as obvious. It's not as acute. But it's a much bigger problem and one that's harder to deal with.

Also, a house that is "worth a lot of money" is only worth a lot of money on paper. To actually get the money for my house, I'd have to sell it. Then I and my family would have nowhere to live. We'd have to get another house. And because of widespread attempts to keep housing in short supply, that place would be expensive. High property values only help you if you are planning to move out of the neighborhood to somewhere cheaper, or if you're a very wealthy person who invests in multiple properties.

I think letting people live in our neighborhood is good for the neighborhood. The suggested support letter says that current conditions "[allow] small businesses to flourish". But what small businesses need to truly flourish is more customers. More people nearby means more customers for local businesses. More people means more money flowing, more chances for business to develop, more goods and services on offer. I would like to see vibrant stores occupying those vacant storefronts on Spruce Street.

I don't expect many people to be persuaded by this next point, but I have to put it in. I think allowing new people to share our neighborhood is part of the responsibility of living in a civil society. Compare it with jury duty. Nobody likes jury duty. It's inconvenient and troublesome. But we do it because we want to live in a country with jury trials, and we can't have citizen juries if we, citizens, don't serve on juries. I've been a Philadelphia homeowner since 2002. I'd rather have a house that's worth less, on paper, in a neighborhood and a city that are better to live in, one where people who want to live here can afford to do it. Our neighborhood is great! I've loved it since I first moved here in 1990. I want other people to enjoy it as much as I do.

Finally, when community organizations oppose development they often make some claim about "preserving the historic character of they neighborhood." Sometimes that might even be true. But it's clearly not true in this case because this neighborhood has had apartment buildings — low-rise and high-rise — since the 1920s. Garden Court apartments, sixteen stories high, was built before any one of us was born. Writer Isaac Asimov rented an apartment at 47th and Walnut back in the nineteen-forties, in an apartment building that is still there today. Anyone who moved into our area in the last hundred years knew that they were moving into a mixed-use neighborhood where there were rowhouses and semi-detached houses and apartment buildings, all mixed together. Apartment buildings are part of the historic character of our neighborhood, and to say they aren't is just not true.

The suggested letter to the Historical Commission says:

Spruce Hill’s significance lies partly in its variety of housing types that have historically housed an equal variety of people. The diversity of living arrangements and people make the neighborhood unique and valuable.

I agree! Let's keep doing that. Let's work for a more inclusive, growing, evolving neighborhood and for a thriving city that people can afford to live in.

Addendum 20240705

Stuff I thought about putting in the letter, but did not. I've learned a little bit in the last 40 years.


[Other articles in category /politics] permanent link