In fact, why choose? So here’s what I’ll talk about: artificial intelligence and Prolog, Slaughterhouse-Five and Tralfamadorians, and, because I assume I write for people who know nothing about CS, recursion.
I’ll start with recursion. You have a stack. It’s a narrow empty column that you can put things into, one on top of the other. When you want something that’s inside the stack you need to pull out everything that’s on top of the item you need. When you’re putting things in to the stack you’re pushing. When you’re taking things out of the stack you’re popping.
Now, you have a box containing a ball point pen (Piano), and a box. Inside the smaller box there is another ball point pen and a box. Inside the third box there is another ball point pen and a box. And so on for some finite number of boxes. You want to count the number of ball point pens that write. Suppose the boxes are labeled N to 0, with 0 as the label of the smallest box (the one contained in all of the boxes). Logically, the total number of functioning ball points the Nth box contains is just the number of functioning ball point pens contained in N-1th box, if the pen the Nth box contains doesn’t work, or plus 1 if the pen it contains works. This definition of the number of functioning ball point pens is recursive. It’s recursive because part of the definition is using the definition itself.
But where does it all stop? What do I do when I’ve run out of boxes to open? Without any more boxes to open, how will I find out how many functional pens I have? There is no N-1th box! *Brief panic attack*
It’s OK. Eventually, when you have no more boxes to look in to, I will let you know if your pen is working or not without asking you how many your containing box contains. I’ll understand. Sometimes, a box doesn’t contain a box and a ball point pen. Sometimes, all it contains is a lonely ball point pen. In other words, I’ll have two definitions of the number of functioning ball point pens: one for boxes that contain a box, and one for boxes that contain no box.
Now, I have a stack full of things. I pop an item, perform some voodoo on it. I now pop another item, an untarnished just popped thing. I take this untarnished just popped thing, perform some voodoo on it, and combine it with the previously voodoo-ed item I had just popped to create a new voodoo-ed item. I repeat till I have no items on my stack. I’ve just recursed using a stack. You could think of the voodoo-ing as the counting of functional ball points.
By voodoo-ing both before and after I’ve found a certain value, or by branching out at each level more than once (each box contains two or more boxes), I can do some truly awesome things with recursion that would otherwise be extremely hard to achieve. For example, I can figure out the best chess move to make, or draw pretty fractals.
In Prolog, which is a programming language for Artificial Intelligence, you don’t actually program your computer the way you would with a language like C++, or Java. You don’t tell it what to do. You ask it to determine if something is true or false on the basis of logical rules. For example, Maheen blogs when Kamil is nagging her and Maheen is not lazy. Now your computer will go through whatever values of Kamil and Maheen you have provided to it. Is Kamil nagging? Is Maheen lazy? If your computer finds the ideal combination of Kamil’s nagging and Maheen’s non-laziness, it will draw a new conclusion about Maheen – Maheen blogs. A solution would exist. Recursive definitions form a huge chunk of Prolog programming because they logically define where as the alternatives (for loops, etc) do not. The smarter the rules I create, the more correct my computer’s logical conclusions would be. Up till now, that’s what my intro to AI course has been about. Creating smarter and smarter rules for a computer to follow and fit in values for.
In another course, Discrete Geometry, I find myself wishing I could picture more than three dimensions in my head. Tralfamadorians, an alien species in Vonnegut’s Slaughterhouse-Five, do exactly that and see the universe in four dimensions, with time as their fourth dimension. For them, all moments in time simply are, just as, for us, space in a given moment simply is - there are no alternatives for that moment. Tralfamadorians know that how you arrived to a moment in time and where you will go afterwards are immutable. Consequently, they find the idea of free will absolutely baffling. Though the idea isn’t exactly new (think interventionist gods), Vonnegut still manages to use the idea to create a wonderful and moving anti-war narrative. Here’s my favourite bit. It’s about the book itself.
“It is so short and jumbled and jangled, Sam, because there is nothing intelligent to say about a massacre. Everybody is supposed to be dead, to never say anything or want anything ever again. Everything is supposed to be very quiet after a massacre, and it always is, except for the birds.
And what do the birds say? All there is to say about a massacre, things like "Poo-tee-weet?" ”
And here’s my all time favourite viral video:
Maheen