[an error occurred while processing this directive]

3 cute solutions

stopping at RR crossings

(An adversarial bound)

Bound on algorithm for stopping-car-engine-at-RR. You drive around houston, and sometimes have to stop at train interesections. To minimize gas, do you turn your engine off, or do you idle? (Starting a car costs, say, 1min worth of gas.)

One answer: what is the expected time remaining for the train? We don't know for sure, but we do have some idea about the distribution of train lengths, and might be able to leverage that.

But Suppose Loki were controlling trains: he can change train-length instantaneously. E.g., if you leave your car running, he makes the train long. The momemt you shut off your engine, he shortens the train to none-left, hahaha very funny, loki. Question: faced with a malicious adversary, can we still do not-too-bad?

Clearly, the algorithm of "always keep idling" is no good; Loki will keep adding cars to the train as long as you idle. On the other hand, the algorithm of "always turn off engine immediately" is wasteful — Loki will send lots of one-car trains, which needn't use up much gas, but it will.

Our algorithm:

For comparison: consider Odin, driving around town. [Type of car?] Odin still has to wait for trains, but Loki can't fool with them. Furthermore, Odin is omniscient: he knows how long the train is, when he reaches it.
[Odin sends up his ravens Huginn and Muninn (thought and memory) to measure the train and remember its length irrevocably.]
(All Loki can do is set up the initial timetables to delay Odin's commute. What train-lenghts might Loki choose, to maximize Odin's annoyance?)

So, how well can we do against Loki, as compared to Odin (who doesn't face Loki and is omniscient)? Surprisingly: we can guarantee we'll never use more than twice as much gas than Odin! How:

If the train is ≤1min, we are optimal (and use as much as Odin). If the train is 1:01, we use 2min of gas where Odin used 1min. For any train over 1:00: we use 2min of gas; Odin uses 1min.

Translating back to a laptop computer OS, and the problem of seeing a user not making disc accesses, and wondering whether to stop spinning the disk (to conserve battery power).

Loki corresponds to a capricious user who accesses the disk just when you least want it to, while Odin corresponds to a scheduler which is so smart it can actually predict when the user will next access the disk. The result translates to, a simple algorithm which even when facing a ill-behaved user, will only use twice as much battery-power (on disc spin-up) than the omniscient scheduler.

Compare against: Doing user studies and measuring real-life distributions on disc spinning (and agreeing on what your distribution of "typical" users is), and then being able to come up with an algorithm for that distribution and then proving that it's worst- or average-case performance isn't much worse than optimal/average.
For such a simple algorithm, the simple approach isn't so bad! (in a quantified, provable sense)

Mental Poker

(An unexpected Public-key application)

How to play poker over the phone (or email), agreeing on what cards are being drawn (w/o th other side knowing), and be satisfied they're not cheating?

Sounds impossible. Of course, it seemed unlikely we could make a code where, w/o pre-arrangement, I could securely broadcast my encrypted credit card over the net, and only amazon could easily decode it.

Review public-key cryptography:
public key e,n; private key d, such that ed=1 mod (..) well, Med ≡ M1. Encrypted message is Me (mod n); to decrypt look at (Me)d (mod n) = M1 (mod n) [through math].
Observe: If M encrypted by two different codes e1,e2, it can be unlocked via d1,d2 in either order: (((Me1)e2)d2)d1 = (((Me1)e2)d1)d2
(We say that the encrypting and decrypting functions are associative.)
[What about the order mod is applied in? Chinese Remainder Th'm?]

Okay, now to our poker game: Two players, A and B.

  1. Start with 52 cards (strings) c1=``This is the Ace of Spades.'', … c17= ``Here we have the four o' Hearts'', etc.
  2. Player A will take these and encode them using their public key ea, ending up with strings Ea(ci) for each i.
  3. Player A gives B these 52 encrypted messages (in a random ("shuffled") order).
  4. B will take these encoded strings (about which they know nothing), further encrypt them with their own key, getting Eb(Ea(ci))).
  5. Player B now presents these 52 double-encrypted messages (in a random ("shuffled") order) for all to see.
  6. For either player to draw a card, they choose one of the doubly-encrypted strings, and ask their opponent to decrypt it.
    We'll consider at each player separately, even though they each do the same thing:
    1. If player A choose a string Eb(Ea(ci))):
      1. Player A has no idea what it could be (since it's encrypted by B).
      2. Player A asks player B to decrypt the string; player B does so and responds with Db(Eb(Ea(ci))) = Ea(ci).
      3. Player B doesn't know which card this is (since it's encrypted by A's key).
      4. Player A can now decrypt this to get Da(Ea(ci)) = ci, the original string.
    2. If player B chooses a string, the corresponding procedure is followed.
      Note that in step (ii) we rely on Da(Eb(Ea(ci))) = Eb(ci).
      This is where we need the fact that en/de-crypting is associative.
They can then play out their hand. (No further encrypting needed, until they quit.)
Discuss: Hmmm — how to guard against a player saying "gee, I just decrypted this, and whaddyaknow, it's the Ace of Spades!"?

Proving w/o Revealing

(a 0-knowledge proof, incl. a probabilistic argument)

Background: A tough problem (the 10-coloring problem): Admissions has an entering class of 600, and is aware of exactly which students know which others (via same high school, or state competitions, or whatever). They would like to assign the students to 10 colleges, so that no two incoming students already know each other. The big question is:

This is known as the 10-coloring problem — equivalent to: given a graph can you color each node one of 10 colors, such that any nodes with an edge between them are different colors.

[Brainstorm for a second: what are a couple of conditions that would make this impossible? What is a brute-force solution? What is its running time?]

No algorithm for this is known beyond brute force. (Even 3-coloring is hard; 2-coloring becomes trivial.)
The registrar might be running their program all summer long without finding a solution as the deadline draws nigh…. We won't solve the problem either. But we'll daydream about what happens if I happen to stumble upon a solution…

Suppose I happen to know a way to allocate the students, and want to sell my solution to the registrar in exchange for an A+ in LPAP. But we don't trust each other:

It turns out, there is a clever way to prove to the registrar that I have a solution with high probability, w/o revealing even a hint as to what the solution should be. (Strangely: they'll become convinced there is a solution, but they won't be able to convince others that there is a solution!)

Here's a way for the registrar try to trip me up, if I'm cheating:

  1. I write down an assignment from student to college, but cover up each person's college.
  2. The registrar chooses two students who know each other, and has me reveal the college I wrote down for those two. [Note that this provides no new information to the registrar — all they find out is that my purported solution assigns two friends to different colleges (thay already know any solution must do that; the names of the college aren't important, if there are only two students involved).]

How to make them more sure? Repeat this. Uh-oh: while it was okay for them to find out that I put A,B into brown,sid resp.; but I don't want them to then ask about A,C and thereby learn whether my solution as B,C together or not (supposing B,C don't know each other.) Solution: I'll re-name the colleges in my sol'n every round, to avoid giving away actual assignments. (Think of mapping each college to a color, and using different colors on successive trials — chartreuse, lemon chiffon, ….)

How many times needed to repeat, to inspire confidence that I have correct solution? We can easily compute this.

Question: Why do we need to try more than |E| times? — after all, isn't registrar happy after verifying each edge isn't violated?
Well, if were cheating, I might have two different false almost-but-not-quite solutions. If I realize the registrar is only asking about each edge once, then after they ask about the edge that one of my solutions is wrong on [hopefully I was using my other solution when they asked that], I'll start using the solution which I know to be good on all remaining edges, and I would convince the registrar even w/o a solution. So the registrar had better go back randomly and re-ask about edges, to keep me honest!

Note: If the registrar takes two names who don't have an edge between them, and repeatedly asks you whether your assignment put them in the same college, they might collect strong evidence about your solution!
Solution: Only answer (provide keys) for the registrar if they ask about students who went to high school together.

Evaluation forms

Target audiences: Me; My boss; (selectively:) TA/labbies.
Feel free to comment on:

Also, the anonymous online form still available (throughout summer).

[an error occurred while processing this directive] [an error occurred while processing this directive]