The (1st annual?) π day anime and mathematics lecture

Happy $\pi$ day. We’ll begin with an obligatory video.

One of the reasons I enjoyed Summer Wars so much is because the main character’s superpower is math. Well, okay, you say, he’s really good at math, but so what? A lot of people complain about the implausibility of OZ, but those of us with a basic understanding of cryptography and number theory will have been drawn to Kenji’s quick problem solving work with an eyebrow raised. So let’s talk about why Kenji is a wizard.

Kenji doing some friggin mathematics

Kenji doing some friggin mathematics

We’ll start with modular arithmetic, which Kenji mentions to Natsuki on the train ride to Ueda. When we divide numbers, we often end up with remainders. Suppose we divide some integer $k$ by $N$ and we get a remainder of $r$. Then we say that $k$ and $r$ are equivalent $\bmod{N}$ and we denote that by $k = r \bmod{N}$. Because it’s how division works, for any integer $k, r$ will be some number from $0$ to $N-1$. It turns out a lot of arithmetic operations work the same way in modular arithmetic: adding, subtracting, and multiplying numbers and then taking the modulus of the result will give you the same number as adding, subtracting, and multiplying the moduli of the numbers you started out with.

However, division doesn’t work as we would expect it to. So we have to think about division (or the equivalent operation) differently. Instead of thinking of division as splitting a group of stuff into smaller groups, we’ll think of it as multiplying by an inverse. What’s an inverse? Well, we can try thinking of it in terms of addition. It’s pretty intuitive that subtraction is the opposite of addition. If we have some integer $k$, then the additive inverse of $k$ is $-k$. When we add $k$ and $-k$, we get $0$, the additive identity. The identity is just the special number that we can add to anything and get that same thing back unchanged ($n+0 = n$). In the same way, if we multiply $k$ by its inverse, $k^{-1}$, then we’ll get $1$, since $k \times 1$ is just $k$ again. What this means is that the inverse of $k \bmod{N}$ is just some other number $j$ from $0$ to $N-1$ such that $j\cdot k = 1 \bmod{N}$ and it’s just multiplication again.

Now, the problem with this is that it’s not guaranteed that there’s always an inverse hanging around in $\bmod{N}$. In particular, if $k$ and $N$ share any divisors, then $k$ won’t have an inverse $\bmod{N}$. This is interesting because it also tells us that if we consider integers mod a prime number $P$, then every integer $\bmod{P}$ has an inverse, since $P$ doesn’t share any divisors with any integers from $0$ to $P-1$. We call these things that have inverses units. So if we have a unit $k$, then $k^m$ is also a unit, for any integer $m$. We even have a funny function $\phi$ defined such that $\phi(n)$ is the number of units in $\bmod{n}$.

Love Machine solicits help

Love Machine solicits help

So taking everything we’ve learned, we can set up a cryptosystem! The one we’ll be looking at is called RSA, after the guys who invented it. We have Bob who wants to securely send a message $M$ to Alice. Alice chooses two prime numbers $p$ and $q$ and figures out $m = pq$. She also goes and figures out $\phi(m)$, which happens to be $(p-1)(q-1)$. Finally, she picks some integer $k$, a unit in $\bmod{\phi(m)}$. She lets everyone know $m$ and $k$, but she keeps $p$, $q$, and $\phi(m)$ secret.

So Bob wants to send $M$, which is just his message conveniently in number form. He makes $M$ into a number between $0$ and $m$, and if $M$ is too big, he can just break it up into chunks. Bob figures out the smallest $b$ such that $b = a^k \bmod{m}$ and sends $b$ over to Alice. Now, since Alice has $k$ and $\phi(m)$, she can also find $k^{-1}$ pretty easily. Once she has that, she can get the original message by figuring out $b^{k^{-1}} = (M^k)^{k{-1}} = M \bmod{m}$, since $kk^{-1} = 1 \bmod \phi(m)$.

The interesting thing here is that all of the information is out there for someone to encrypt a message to send to Alice, but no one is able to decrypt it. Well, they’re able to decrypt it if they know what $p$ and $q$ are, since once they’ve got that, they can get $\phi(m)$. But it turns out getting $p$ and $q$ from $m$ (which Alice just throws up on the interwebs) is really hard. And it really works for reals, because RSA is pretty widely deployed for things like keeping your credit card information safe while you send it through the tubes to Amazon.

A conveniently displayed ciphertext

A conveniently displayed ciphertext

Let’s go back and think about units some more. Of course, there are only $N$ numbers in the integers $\bmod{N}$, so there’s a point at which $k^m$ is just $1$ again and starts over. If $k^m = 1 \bmod{N}$, we say that $m$ is the order of $k$. But why do we care about finding the order of $k$?

It turns out finding the order of elements is very, very similar to factoring an integer into primes and other related problems, like discrete logarithms. If we can find orders of elements, it won’t be too hard to figure out how to factor a number. In this case, the eavesdropper wants to figure out what $p$ and $q$ are, so they’ll want to factor $m$. And it turns out a lot of other public-key cryptosystems (like elliptic curves) are based on the difficulty of factoring.

How hard could it be? Well, we could just check every possibility, which doesn’t seem that bad for a number like 48, but once we get into numbers that are hundreds of digits long, that might start to suck. It turns out the fastest known algorithms for order finding take approximately $e^{O(\log N \log \log N)^{\frac{1}{2}}}$ steps. Current key lengths for RSA are at least 1024 bits, which would give us about 4.4 x 1029 operations. Assuming three trillion operations per second (3 GHz), it’d take a PC about 4.7 billion years. Sure, you could just throw more powerful computers at it, but they’d just double the key size and suddenly, you’d need to do 1044 operations.

It's a lot easier to write math than typeset it

It's a lot easier to write math than typeset it

Well, that’s not entirely true. One of the breakthroughs in quantum computing was coming up with a fast algorithm for factoring. It turns out quantum order finding takes $O((\log N)^2 \log \log N \log \log \log N)$ steps, which, for a 1024-bit key is just over 60 operations. Doubling the key-size to 2048 bits only increases the number of operations by just over 20. Unfortunately (or fortunately, because we’d be pretty screwed if someone could easily break RSA right now), we haven’t built any quantum computers that large yet, nor are we capable of doing so anytime soon.

tl;dr – Kenji is a quantum computer.

Count von Count vs. Cantor

A combination of an incidental argument over whether the cast of Sesame Street or the Muppet Show would win in a fight and reading about Internet crazy people refusing to believe the uncountability of the real numbers lead to this. I hope you like math.

So we know that Count von Count (colloquially known as The Count) loves counting. According to Wikipedia, he will count anything and everything, regardless of size, amount, or annoyance he causes everyone else. The logical question would be, what happens when we present The Count with an uncountable set like the set of real numbers, ℝ (unless you are a crazy person)? Can he count it?

The answer is of course he can, he’s the goddamn Count.

What are the implications? Basically, The Count can enumerate any set, whether it’s uncountable or not. This means that to The Count, every set is recursively enumerable. This means that for every set S, S and its complement S’ are recursively enumerable. But this means that every set S is recursive.

So, now we consider the halting set H = { (P, w) : program P halts on input w ∈ Σ* }. From above, we have that H is recursive (since H’ is recursively enumerable). But this means that H is decidable. This means that The Count can decide the Halting Problem, and thus, can decide any undecidable problem.

What we conclude is that The Count’s power isn’t to count, but is, in fact, to break logic.

fffff – a tale of failures.

Since I have a blog, I figure I should blog once in a while. Don’t worry, I’ll be back to blogging too much about animu and politics shortly. So this term has been not quite as keikaku as I’d have liked. This has been fairly enlightening as I try to figure out just wtf I’m going to be doing and how future terms are going to be affected.

Act I: Analysis

I’d already mentioned before that Complex Analysis was a crazy roadblock that put me on to the road to proposed and much easier plan requirements. This was clearly because I was insufficiently prepared for the material. Even though the lecture material made sense as we went through it and the textbook was pretty much the same thing, it was determined that I didn’t have the adequate foundational knowledge in analysis and the intuition that comes with solving those sorts of problems.

So, this was for the best, it seemed. After all, dropping one course wouldn’t be too bad.

Act II: First-Order Logic

Now this, this is failure. This is where we learn that the Rudy 08 strategy does not work when applied to coursework. After not having gotten a passing mark on any assignment, I decided to seek the advice of the TA before the midterm. It boiled down to understanding the solutions to the problems, which I felt like I had a pretty good handle on, especially after relearning everything.

As it turns out, it wasn’t good enough and I failed the midterm. I decided that the chances of my passing were very slim at this point and decided to abandon ship.

This course was a very interesting experience for me. Unlike Complex Analysis, where I was insufficiently prepared, this course should have been cake. I did well in my first logic course and I enjoyed computability theory in the CS context. It turns out that that would be my downfall, because it seems that that was some sort of mental block that made it impossible for me to solve the problems in such a way that it would satisfy the subject in a pure mathematical context.

I don’t think I’ve ever had a course baffle me like that before. I’d go do an assignment, feeling confident that I’d solved the problems fairly competently and find that I was doing it wrong. I’d look at the solutions and try and see what went wrong, internalized the mistakes, and took a stab at the next assignment and, again, felt confident. The cycle would repeat all the way to the midterm.

Epilogue

I walked away from this entire debacle understanding just where my interests in mathematics lie. The things that attracted me to pure math wasn’t exactly the purity and the theory. It was exactly the things in math that I found cool (algebra and number theory) and pure math was the only way I could study those things. And as much as I might want to think otherwise, I’m still much more of a computer scientist than any other kind of mathematician.

3B: アニメじゃない

By popular demand, here’s a post that’s not about animu. Let’s see what delights my 3B term is bringing me.

CS 462: Formal Languages and Parsing (He)

This was one of the courses I was most looking forward to. And then I found out the prof I that I thought was teaching the course (who is a really awesome prof) was going on sabbatical. щ(゚Д゚щ)

The actual prof isn’t that great in lecture. His speaking isn’t very good and neither are his board notes. He’s pretty good when emailed though, so I just read the textbook and imagine it’s the author (who was the prof I wanted to get) lecturing instead and I just take notes.

The course itself is pretty cool. It seems to be more CS 360 stuff and in the same order too, going from finite automata and regular languages to context free languages and then to Turing machines. Thank God for Jeffrey Shallit’s book, A Second Course in Formal Languages and Automata Theory. I think I’m going to keep it.

CS 466: Algorithm Design and Analysis (Biedl)

This is another really cool course. In terms of content, it seems like it’s just more CS 341: here’s a problem, now let’s try to solve it and refine the solution. Now, we have a few more techniques that didn’t make it into CS 341.

I really liked the prof for this course when I took CS 360, enough to change my plans and push STAT 231 even later. But, having Timothy Chan guest lecture one class sort of convinced me I probably would’ve been okay if I’d decided to hold off on it until spring. Still, really good prof with really good board notes, although I find her equations and formulas really, really verbose. This preference for verbosity over notation seems to be a thing that’s really common among CS profs, actually.

PMATH 352: Complex Analysis (Spronk)

This was probably the class I was most worried about, since the last time I had anything to do with calculus was in 2A, which was two years ago. And it turns out my fears were completely realized. The class itself seemed pretty interesting, but it became clear that I had no idea what was going on when the time came to do assignments.

The prof was really helpful when I talked with him about it. This eventually lead to me dropping the course on his suggestion and altering my program plan to a more achievable one. He’s also really good in lecture and is one of those profs that proves and notes every detail. He writes really fast though.

PMATH 432: First Order Logic and Computability (Csima)

So I learned too late that I probably should have chosen PMATH 434 (Computational Number Theory) over this one. The course content for this was essentially a more intense version of CS 245 combined with what I believe will end up being the solvability parts from CS 360 and CS 341. Well, the stuff on solvability might make it worth taking this course, so we’ll see. This course is also kind of annoying because there’s always something that I’m missing in a proof that causes me to hemorrhage marks.

The prof is alright and has pretty good board notes, although she does get mixed up a bit sometimes. I don’t blame her, when you’re going on about models of stuff and interpretations of stuff, it’s not easy to keep track of it.

PMATH 442: Fields and Galois Theory (Liu)

Best course of 3B. Remember when I said rings and fields were awesome and groups were kind of meh? Well, Galois theory tells us that groups can be alright. It just takes something interesting like fields to make groups cool, that’s all. So yeah, field theory (and by extension, ring theory) is pretty awesome.

The prof for this course is great. Her accent needs about one class to get used to and then you’re good. Best board notes of the term. The thing that sets her apart, though, is that she cares about the students. She’s always asking us for our opinions on things about the class and tries to make sure that we understand everything and reminds us that if we’re having trouble, we can always ask her for help and stuff.

3A: Over the halfway hump

Even though my carefully crafted course sequences were thwarted, I’ve gotta say that 3A has been my most enjoyable term so far.

PMATH 346: Group Theory (Lawrence)

I was expecting this to be as killer and awesome as PMATH 345. Fortunately, it wasn’t as killer, because the prof was nicer to us on the midterm. Unfortunately, I don’t really like groups as much as rings. Oh well, still pretty fascinating. In theory, groups come before rings, but rings are so much cooler. The prof is pretty good.

PMATH 340: Elementary Number Theory (Ingram)

I was expecting this to be easy and interesting. I was right about the easy. The first half of the course was essentially MATH 135 over again. I didn’t think the prof’s lecturing was terribly interesting, but he had excellent course notes which allowed me to not go to class. I would have loved to have Vanderburgh though.

CS 360: Introduction to the Theory of Computing (Biedl)

This class is pretty awesome and the prof is pretty awesome. One of my favourite classes, this one starts with finite automata and regular languages, moves on to context-free languages and grammars, and ends with Turing machines and solvability. It wasn’t hard to pick up the material and it’s super interesting. The prof is so awesome that I reworked my course sequences so that I could take CS 466 (Algorithm Design and Analysis) with her.

CS 341: Algorithms (Shallit)

This is also another fascinating course. Basically, the course is structured so that in the first part, you go through techniques to design algorithms and examine problems and various algorithms to solve those problems. After that, you move on to looking at lower bounds on problems. Then, you have a look at graph problems: minimum spanning tree and shortest path algorithms. The final part of the course is the most interesting, looking at complexity classes and NP-completeness in particular. The prof is also really awesome. I’m looking forward to having him again for CS 462 (Formal Languages and Parsing).

CS 350: Operating Systems (Aboulnaga)

Operating system theory is kind of interesting, but not enough to keep me concentrated after the other two CS lectures. Oh well.