In Boolean algebra (named after George Boole) you manipulate the symbols T (for true) and F (for false). This is useful to help analyze, understand, and simplify the flow of logic in computer programs and electronic circuits. The **NOT** function swaps T to F and vice-versa, for example **NOT**(F) = T and **NOT**(T) = F. One way to combine two values is with the **OR** function: if you give it two of the same input it gives you the same one back, but if you give it a mix of T’s and F’s it gives you back T. For example **OR**(T, F) = T and **OR**(F, F) = F. **AND** does the same thing, but it gives you back F if the inputs are a mix of T and F.

A couple of miraculous things happen from these definitions. One is DeMorgan‘s Law, which says that

**NOT**(**AND**(*x*,*y*)) =**OR**(**NOT**(*x*),**NOT**(*y*)), no matter what the values of*x*and*y*are;- similarly
**NOT**(**OR**(*x*,*y*)) =**AND**(**NOT**(*x*),**NOT**(*y*)).

In a sense, this law says that **NOT** turns **AND** in to **OR** and vice-versa.

Another one is that we get a distributive law

**AND**(*x*,**OR**(*y*,*z*)) =**OR**(**AND**(*x*,*y*),**AND**(*x*,*z*)), no matter what the values of*x, y,*and*z*are;- similarly
**OR**(*x*,**AND**(*y*,*z*)) =**AND**(**OR**(*x*,*y*),**OR**(*x*,*z*)).

So this is like arithmetic where *x**(*y*+*z*) = *x*y + x*z* but continuing the analogy, somehow for Boolean algebra we also have *x+y*z = (x+y)*(x+z)*, which is not like arithmetic.

Finally, there is a function **XOR** (exclusive or) which is a cousin of **OR**. Note that in English sometimes we use “or” to mean the “**OR**” function described above: “you’re not allowed to drive if you have no license **OR** you’re drunk” (or both). But in English sometimes “or” means “either but not both,” like “this combo comes with a salad or fries” — in this case you can’t get both. This is **XOR** in Boolean logic: it has the same behaviour as **OR** except that **XOR**(T, T)=F instead of how **OR**(T, T) = T. It turns out that there are a couple of ways to build **XOR**,

**AND**(**OR**(*x*,*y*),**OR**(**NOT**(*x*),**NOT**(*y*))) is one definition of**XOR**(*x*,*y*)**OR**(**AND**(*x*,**NOT**(*y*)),**AND**(**NOT**(*x*),*y*)) is another equivalent definition of**XOR**(*x*,*y*).

I’d call this equivalence another law.

Here are some questions:

**Troolean logic**. Let’s say we extend Boolean logic to have a third value ? meaning “I don’t know.” So we should define**NOT**(?)=?, as well as**OR**(F, ?) = ? and**OR**(T, ?) = T since in the first case we can’t tell what the result of OR should be, but in the second it should definitely return T. Show that we can define**AND**and**XOR**on all pairs of inputs involving T, F, and ? so that all of the laws above hold.**Quadroolean logic**. Instead, we could extend Boolean logic to have 4 values: F, T, VF and VT, where VF is “very false” and VT is “very true.” Thus**NOT**(VF)=VT and**NOT**(VT)=VF makes a sensical definition, as well as**OR**(VF,*x*) =*x*for all*x*and**OR**(VT,*x*) = VT for all*x*. Show that we can define**AND**and**XOR**on all pairs of inputs involving T, F, VT and VF so that all of the laws above hold.**n-****oolean logic**. Show that for any integer*n*> 1, we can come up with a set of exactly*n*symbols including T and F, and definitions of**NOT**,**AND**,**OR**and**XOR**for them so that all of the laws above hold, plus a few others:**NOT**(**NOT**(*x*)) =*x*; the commutative property**AND**(*x*,*y*)=**AND**(*y*,*x*) and similarly for**OR**; the associative property**AND**(*x*,**AND**(*y*,*z*)) =**AND**(**AND**(*x*,*y*),*z*) and similarly for**OR**; the idempotent laws**OR**(*x*,*x*) =**AND**(*x*,*x*) =*x*.- Are there multiple truly different
*n*-oolean logics? - Does the XOR equivalence law follow automatically from all of the other laws? (This one I don’t know the answer to.)

Together with Bill Cook, Bill Pulleyblank and Lex “Bill” Schrijver, Bill authored the celebrated textbook Combinatorial Optimization. This book really attracted me to combinatorial optimization as a graduate student. A couple of times this week his book has been cited for its excellent Amazon reviews, including this unique one:

This book was thoroughly written by great-minded Masters. It is well-organized in their topics and presentation. However, the book details is unbalnced, some chapters are overwhelm the data, and some others are insufficient. By the way, I graded this book a Very Good one. Worth Reading !!

I certainly agree with the first two sentences and the last one!

There were three days of talks from visitors. Here are just a few highlights out of the many excellent talks:

- Bill Pulleyblank described three applications of integer programming to sports scheduling, including re-alignment of the divisions of the National Hockey League, which he modelled as a quadratic assignment problem.
- Bill Cook, who according to Pulleyblank “regularly solves TSP instances with 300 zillion cities on his iPhone while he’s talking,” gave a very compelling talk on the TSP (travelling salesman problem). There is a movie called “Travelling Salesman” coming out in a few days, where the protagonists find fast algorithms for TSP and therefore are able to break encryption, hack in to banks, et cetera. Bill Cook did really make a TSP app for iPhone, but as a disclaimer, the movie is not based on a true story. As an aside, I really recommend reading his TSP book, which has quite a lovely balance of mathematical details and storytelling.
- András Sebő described his joint work with Jens Vygen on graphic TSP. This is a very hot topic: a 1.5-approximation was known since the 1970s, and in the span of 13 months, four separate papers found approximation ratios of 1.4999999999, then 1.461, then 1.444, and now 1.4 by Sebő and Vygen. The new result uses some of the machinery of Mömke-Svensson (the 1.461) and most unexpectedly of all,
*matroids*! I will have to read this paper in detail because it seemed to be a tour de force in terms of using many different tools, while still being very simple overall. You simply try to keep most of your ears (from an ear decomposition) long (e.g., having ≥5 edges). It also gives the best known results for unweighted*s*–*t*tours and connected*T*-joins. - Jim Geelen gave a very nice new characterization of graphic matroids, joint with Bert Gerards; here is a nice alternate description that he gave of the result. You are given a tree, a distinct label like “5” for each edge, and some paths in the tree. Every path in the tree can be described by the set of labels it contains. Now I just write down the sets of labels corresponding to paths, but I erase the tree and its labels. Can you reconstruct a tree and paths giving these label sets? And, can you tell when I am cheating, giving you label sets that have no such realization? They show that this problem can be solved just by inspecting a certain system of linear equations. As a bonus, this gives a nice new solution for the
*consecutive ones property*of hypergraphs: given a matrix with 0 and 1 entries, can you permute the columns so that in each row all the ones are consecutive? - and, many other excellent talks on matroids, matchings, and extensions!

It has been a great week, thanks to the formidable organizers and the excellent speakers. Bill is extremely approachable, scientifically adept, and very dedicated: he served as Chair of the department several times. Here is a picture created by Bill Cook, based on a vintage photograph of Bill Cunningham. It shows a picture of a random Euclidean *b*-matching instance, solved to optimality. I believe that the value of *b* is “Bill.”

Happy birthday, Bill!

]]>The diagram above is from a paper of mine which, as I found out today, was published last year! It is in ACM Transactions on Algorithms, although their website still lists the “current issue” as 2010 and they didn’t tell me when it went to press. The paper, joint with Ramki Thurimella, is about using a simple idea from graph theory to obtain dramatic speedups for distributed algorithms. An *Eulerian* subgraph is one with even degree at every node. The *cycle space* is the family of all Eulerian subgraphs; it is a vector space because when you add two Eulerian subgraphs mod 2, the result is another Eulerian subgraph. We show that you can efficiently sample a random Eulerian subgraph and use the samples to quickly determine if the graph is 3-edge-connected, or 2-vertex-connected. The picture above, which is a bunch of pure graph theory, is used in the implementation for the parallel model of computing.

Here is a second picture:

This one is from ongoing work with several collaborators from the Egerváry Research Group in Budapest. It shows a g-polymatroid on the left; if we relax the blue constraint we get the polyhedron on the right which is not a g-polymatroid. This picture was much harder for me to put together! I had drawn these polyhedra originally using Maple and/or Sage, which are great for doing anything polyhedral (even in more than 3 dimensions). But exporting to a .pdf-friendly format was next to impossible! What I have finally settled on is the pst-solides3d package for LaTeX, which is pretty professional and gives you very good control over the appearance.

I also considered using Asmpytote with the media9 package, which lets you actually rotate the 3d diagrams while you are reading the paper! Here is a demo file where you can try it out; it doesn’t work for my in-browser pdf previewer, but is fine when opened as a stand-alone pdf. It seems somewhat less author-friendly and more likely to crash your .pdf reader. But, it’s reasonable to say that the best way to learn about 3D geometry should be to play with the object as if it were in your own hands.

]]>Congratulations to all of the competitors! The teams on which I previously competed, Waterloo and MIT, did pretty well, securing 9th and 22nd places respectively. Harvard was the best North American team, in 7th place. The top 4 teams were very familiar names — to me at least — since they dominate the contest perennially: St. Petersburg State U; U Warsaw; Moscow Inst. Physics & Technology; and Shanghai Jiao Tong U from 1st to 4th.

Like the IOI and its national predecessors for high-school students, the problems require both a good knowledge of how to quickly code common useful algorithms, and powerful problem-solving skills. Here is the problem I liked best this year, which is elegant and challenging, yet with a simple final solution.

**Blobs.** You have several blobs, of different sizes. Your opponent also has several blobs. You will play the following game with them, and the question your program must solve is, *who will win if both players play optimally?* On your turn you can do one of three things:

*Merge*two of your blobs. They are replaced with a new blob, and the size of the new blob is the sum of the sizes of the old blobs.*Attack*. If you have some blob Y, and your opponent has some blob O, such that the size of Y is greater than the size of O, then you can make an attack, which destroys blob O and leaves blob Y unchanged.- Pass.

You win the game when your opponent has no blobs left. For example, if you (the first player) have three blobs of sizes (8, 8, 3) and your opponent has (10, 5, 5), you have a winning strategy which must begin by merging your size-8 blobs into a size-16 blob. Then, no matter what your opponent does, you can attack their blobs from largest to smallest until they are all gone.

As another example, if you have two blobs (10, 6) and your opponent has (9, 8), you again have a winning strategy, but the only winning first step is to attack one of your opponent’s blobs.

The remaining details of the problem statement are,

- you can ignore ties: the input will make it impossible for both players to have blobs of the same size.
- there will be at most 10000 blobs per team at the start, each of size at most one trillion.
- your program should run in less than one second.

You can see the original wording in the problem set (look at problem L) and if you want general ideas on how to solve any of the problems you can check out Per Austrin’s guide.

]]>

The result is in the field of streaming algorithms. Specifically, there is a “streaming” data set which consists of a large number *m* of elements, where each element is some *b-*bit string — actually it is more convenient to think of each element as integer between 1 and *n* := 2* ^{b}*. You only get to see one element from the stream at a time, do a computation and change your working memory, and then the next one arrives. We want to capture some statistical properties of this data set. Storing the entire data set could be done easily in either

First, an easier **puzzle**. Let’s say that we don’t precisely know in advance the total number of items (including repeats) *m* that will arrive, and want to find *m* out. (For the puzzle, we don’t care about the items’ contents.) Evidently we can just count this in a streaming manner using log *m *bits of memory. Can we do it with less? More precisely, can we come up with a good estimate of *m* using only O(log log *m*) bits of memory? I give the answer at the end.

Back to Ravi’s talk. The particular statistic we’d like to count is the second moment. For each string *i*, let *f _{i}* be the frequency of that string, or in other words the total number of times it appears in the data set. Then the second moment is defined as . Put differently, the second moment is the probability that two random elements from the stream are the same, up to a factor of

Ravi’s explanation of how you could imagine doing this was very nice. Think of *f* as a vector in high-dimensional space. What we want to measure is (the square of) the Euclidean length of *f, *but we don’t have the space to explicitly store all of the bits of *f* in memory. The streaming model amounts to discovering the vector *f* in unit steps. The key insight in his explanation is to use the projection of *f* on to a random *d*-dimensional subspace where *d* is logarithmic; analogous to the Johnson-Lindenstrauss lemma, the random length of the projection actually gives us a pretty good estimate of the original length. Moreover, the projection of the sum of the steps is the sum of the projections of the steps. So it suffices to keep a running (vector) total of the sum of the projections of the steps.

A possible problem in implementing this is that projecting on to a *d*-dimensional subspace amounts to multiplying each incoming item (*n-*dimensional unit basis “step” vector) by a *n*-by-*d* matrix, and we cannot store anything of length *n*. To get around this, we let our *n*-by-*d* matrix actually be pseudorandom — that is to say, there should be some small random “seed” so that a computer program can determine the *n*-by-*d* matrix from just the seed. In this way, we don’t need to store the whole matrix in memory, rather just the seed, so that we can just recompute the *i*th row each time an element *i* shows up. In this way we can keep a running count of the *d*-dimensional vector sum and complete the idea.

This result is due to Alon, Matias, and Szegedy, which I have heard called one of the first papers in streaming computation (1996). The paper is nice to read and gives a clean explanation where you project on to random ±1 vectors in a derandomizable way. But this intuition helps me follow the proof idea for second moments (section 2.2). I read it previously (without this intuition), back when I was working on my Master’s thesis, because I had looked at an earlier paper of Morris for estimating the first moment… and this brings me to the puzzle’s solution.

***

You may have already deduced that you would need randomness to solve the puzzle, because with only *O*(log log *m*) bits of memory, our counter could only have polylog(*m*) states, and so only count polylog(*m*) items reliably.

So, let’s say that we have a “log counter” instead. The log counter stores a value *k*, such that our running estimate of the number of items seen so far is 2* ^{k}*. Then, we maintain this counter using the probabilistic method: if the counter currently reads

The paper of Alon et al has a lot of other nice stuff. We saw small-space approximations for the first and second moments; they also formalize a previous idea for the 0th moment (counting distinct items) and show that some higher moments do not admit any small-space approximation. For recent work on this, not a bad place to start is to look at the work of Kane & Nelson et al.!

]]>