This is Knot Coding

Following are the notes from a workshop I hosted for Theta Tau in November 2024.

Hi, I'm Chris Johnson, a professor of computer science here at James Madison University. I got into computer science in order to make things. But not just digital things. Physical things. Things made with math and code but which outlive the computer I use to make them. Our goal in this workshop is for you to make something with math and code: a sticker that you can put on your laptop, water bottle, phone case, or whatever surface.

The thing we're going to make is a knot. You're familiar with knots. People tie them in shoes and weddings. The sense of knot that you should bring to this workshop is that a knot is a meandering path. In math and many works of art, a knot is a circuit. If you start walking on the path, you will arrive back where you started. There are no dead ends or branches. They are frequently used to decorate floors, walls, bodies, and pages of illuminated manuscripts. Consider these examples... TODO.

Mathematicians like to classify things, and they have classified knots. But what would one classify them by? Size and curvature are not terribly interesting characteristics. A knot can easily by tugged or elongated into a longer or curvier knot without really changing it. No, what makes a knot unique is its number of crossings.

The knot with zero crossings is the unknot. It can be deformed into a circle. Any knot with only one crossing can be untwisted into the unknot. Any knot with two crossings can also be untwisted into the unknot. The first real knot has three crossings. It's called the trefoil knot because it can be deformed into a canonical shape that has three leaves. It cannot be untwisted into the unknot. There's one knot with four crossings, two with five, and three with six. But we're not interested in enumerating them all. We just want to make one. Let's talk about how.

Our knot will be constructed as a mosaic. Knot mosaics were proposed in 2008 by a couple of professors at the University of Maryland as a way to diagram quantum behavior. I don't know what that means, but here's what a square knot mosaic looks like. I made this marble maze set for my son...

We want to trace this kind of path out in code. At each edge in the grid, we have a choice between three moves: walk forward or curl left or right. When we put these moves into a sequence in code, we get a nice meandering path:

We can have the knot pass under itself with the dig command:

Digs make the sticker more difficult to apply. They are neat, but you might choose to avoid them.

Here's a more elaborate knot mosaic:

Now it's your turn to make one... When you're satisfied, open the Gear menu and click Send to Chris. Then come find me and we'll cut your knot into a vinyl sticker.

In closing, I'd like to thank you for attending today, designing a knot, and trying out Twoville. Artists employed knots to invoke feelings of endlessness. I can't guarantee that your sticker will last forever, but it will survive long after we shut off the computer. May your computer be merely the place where ideas are born.