Information --- Staff --- Homework --- Reading/Lecture note --- Newsgroup --- Feedback

3 cute solutions

stopping at RR crossings

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.) [You can re-phrase this in terms of battery power and disc spin-down in a laptop, if you want a less silly application.] 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: - When we reach a stop, wait one minute, idling. - If train is still coming by, then we turn engine off. 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: - When we reach a stop, wait one minute, idling. - If train is still coming by, then we turn engine off. 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 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

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, M^e^d=M^1. Encrypted message is M^e (mod n); to decrypt look at (M^e)^d (mod n) = M^1 (mod n) [through math] Observe: If M encrypted by two different codes e1,e2, it can be unlocked via d1,d2 *in either order*: (((M^e1)^e2)^d2)^d1 = (((M^e1)^e2)^d1)^d2 [What about the order mod is applied in? Chinese Remainder Th'm?] Okay, now to our poker game: Two players, A and B. Player A will encode messages "this is the ace of spades", "this is the king of spades", ..., using their public key e_a. Player A gives B these 52 encrypted messages (in a random ("shuffled") order). B will choose 5 at random, and "deal" those back to A (who can decrypt them) (B is satisfied that A's hand is random, but has no idea what it is.) B then takes the remaining cards and re-encrypts them (using e_b); B shows these twice-encrypted cards (in random order) to A, who chooses 5, decrypts those 5 using d_a (getting something which is now only encrypted via b's code), and gives them to B. Again, B has randomly-chosen cards but A has no idea what they are. 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 hey it's the Ace of Spades, what do you know"?

a 0-knowledge proof

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: - Is this possible, for this year's class? - If so, what is such an assignment? 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.) Okay, now to our scenario: I know a way to allocate the students, and want to sell my solution to the registrar for an A+ in LPAP. But we don't trust each other: - if I tell my solution first, I suspect the administration will say 'yeah we just figured that out too on our own, thanks, bye'. - the administration fears that if they put the A+ on the transcript and send it to MIT as I request, that I'll turn out not to know the answer and have just fooled them. 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: I write down an assignment from student to college, but cover up each person's college. 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).] - If I have a good solution, they will always be separate colleges. - If I had a bogus solution, I must have at least one bad edge (both students the same college); the Housing office will choose a bad edge with probability at least 1/|E| >= 1/n-choose-2. So if was wrong, I'll pass this test "only" 1-1/(600-choose-2) of the time. [matt m's observation: number of edges is bounded by 10*600 (even, 9*600/2), since if any person knows more than 9 others, a priori the graph isn't 10-colorable.] 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, which I alternate; the registrar might try each edge, but never find the sol'n. ======== Evaluation forms Feel free to comment on: - Particular hw problems you liked or didn't like [ebay queries, proofs 1-1, learning-style, programs, waterworld, proofs about programs, counting, flash mindreader] - Particular labbies you did or didn't find helpful Also, the anonymous online form still available (throughout summer).
Information --- Staff --- Homework --- Reading/Lecture note --- Newsgroup --- Feedback

Comp280 Home Please notify us of any broken links, etc. Last modified 2004.Apr.15.