Tuesday, November 19, 2013

Interesting Arguments


An interesting line of reasoning that I came across in my Combinatorial Theory  course is
the minimal element method.

The general outline of a proof using this method is as follows : Suppose you want to prove that a given set of elements satisfy a given property $P$. Let the set of bad elements not satisfying that property be denoted by $\mathcal{B}$. Assume that $b$ is the minimal element of $\mathcal{B}$ in some sense. Then using the assumptions of the claim, show that there exists  another element $b^\prime \in \mathcal{B}$ such that $b^\prime < b$.

Another interesting style of argumentation which is generally seen in information theoretic arguments is the probabilistic method in which a deterministic solution to a given problem is shown to exist by constructing a random candidate for a solution, and showing that this candidate solves all the requirements of the problem with positive probability.

Saturday, October 26, 2013

Typesetting math equations in Latex

While writing any document in $\LaTeX$ using the amsmath package many wishes need to fullfilled. The most cumbersome task that troubles me frequently is typing the right and left delimitors (say \lvert \rvert) seperately. Why can't there be a command that does that on its own. Turns  out that somebody did write a package to improve upon amsmath : mathtools .

The most useful feature I found is, allowing the user to define paired delimitors For example, instead of typing,
    \left\{ \frac{a}{b+c} \right\}
You can just define paired delimitors and use them as follows,
    \usepackage{mathtools}
    \DeclarePairedDelimiter{\set}{\lbrace}{\rbrace}
    \set*{ \frac{a}{b+c} }
The output is the same as before,
$$\left\{ \frac{a}{b+c} \right\}$$

Using the * after the command resizes the delimitors to fit the vertical length of the expression.

Another interesting tool in this package is allowing tags for equations to have user-defined labels. See section 3.2.2 in  mathtools .

Another great tool for publishing documents on the web is mathjax. Recently mathjax allowed users to use mathjax scripts through their plugins on popular web platforms. 

Wednesday, October 23, 2013

Subadditivity, Limits and Lim Inf

Consider a sub-additive sequence $a_n$ for $n \geq 1$, where sub-additivity is defined as follows :
$$a_{n+m} \leq a_n + a_m$$

Fekete's Lemma says that for any such sequence $\lim_{n \rightarrow \infty} a_n/n = \lim \inf_{n \rightarrow \infty} a_n/n $, which can be easily proved. The proof is as follows-

Let $\lim \inf_{n \rightarrow \infty} a_n/n  = l$. Therefore, $\exists K$ s.t.
$$\left\vert \frac{a_K}{K} - l \right\vert = \epsilon/2$$

Now consider a large enough $L$ such that $ \frac{a_r}{KL} < \epsilon/2, \forall  r < K$. Thus, for every $n \geq KL$ we can write $n$ as $n = Kq + r$, where $q \geq L$ and $r<K$. Therefore,

\begin{align}
\frac{a_n}{n} & \leq \frac{q a_K}{Kq+r} + \frac{a_r}{Kq+r} \\
                        & \leq \frac{q a_K}{Kq} + \frac{a_r}{Kq} \\
                        & \leq \frac{a_K}{K} + \frac{a_r}{Kq} \\
                        & \leq  l + \frac{\epsilon}{2} + \frac{\epsilon}{2}\\
\end{align}

Since this is true for all $n > KL$ the limit exists and is equal to $l$. An alternate but similar proof is given here.



Thursday, October 17, 2013

Pairwise Independence, Mutual Independence and Coding Theory

Consider a set of variables $\{X_1, X_2, ..., X_n\}$. A pair of variables $X_i, X_j$ are pairwise independent  iff $P(X_i,X_j) = P(X_i)  P(X_j)$. And any subset $A_k =\{X_{i_1},X_{i_2},...X_{i_k}\}$ of random variables is mutually independent if

                            $P(X_{i_1},X_{i_2},...,X_{i_k}) = \prod_j P(X_{i_j}) $

Bernstein gave an example of a set of random variables, of which any two are pairwise independent, but the set as a whole is not. A general class of examples which can be easily constructed from this set is the following -

$X_1 = A_1$
$X_2 = A_2$
$X_3 = A_3$
$\vdots$
$X_k = A_k$
$X_{k+1} = A_1+A_2+...+A_k$

where $A_i$'s are a set of i.i.d. mutually independent random variables, uniformly distributed in $\mathbb{F}_2$. Now it can be easily seen that any size $k$ subset $S_k$ of  $\{X_1, X_2, ..., X_{k+1}\}$ is a mutually independent set, but the $k+1$  set  $\{X_1, X_2, ..., X_{k+1}\}$  has a degenerate probability distribution given $A_k$ i.e.
                               $P(X_1, X_2, ..., X_{k+1} | A_k) \in \{0,1\}$

Now one can observe from the example that this is an example of parity check codes (wiki).  Also it is easy to observe that parity check codes are MDS codes. (wiki)

Now, given a general set of $n$ random variables which is $k$ independent (any $k$ subset is mutually independent) is it possible to construct an MDS code from these?

I give below conditions in which MDS code are constructable :

  • The random variables $X_i$ are uniformly distributed in a field $\mathbb{F}_q$.
  • The set $A_n = \{X_1, X_2, ..., X_n\}$ is $k$ independent i.e. any $k$ subset $A_k$ is mutually independent
  • The probability distribution of $A_n$ given $A_k$ is degenerate i.e.
                                                    $P(A_n | A_k) \in \{0,1\}$

Now, given these conditions it can be easily seen from the proof of the Singleton bound (for general non-linear codes) that $\{X_1, X_2,...,X_n\}$ is an MDS code [length, information bits, min. distance] = $[ n, k, n-k+1]$.

Wednesday, October 9, 2013

Pirates, treasure, and data security

Suppose you have a file that you want to divide between $n$ users. Now the division should be such that whenever any $k$ of the $n$ persons collaborate they know the complete file otherwise they must not have any information about the file.

Interestingly the solution to this problem is related to the solution to the following problem :

Thirteen pirates go on an extended voyage, pillaging and plundering from Africa to Asia. By the end they have quite a stash--too much to take back with them. They decide to lock it in a chest, leave the chest on an island, and come back for it a year later. Of course, not being terribly trusting, they want to ensure that none of them can come back early and claim the treasure for himself. They could just put 13 locks on it and each take a key, but a pirate's life is dangerous--they may not all be around in a year. What they want is for any majority of the original thirteen to be able to open the chest, while any fewer will be locked out. How many locks will it take for them to achieve this? The locks they are using are quite simple. Each key opens only one lock (no master keys), but keys can be duplicated, so multiple pirates can have keys to the same lock.

Solution1:

For the pirate problem you should choose ${n \choose {k-1}}$ locks and distribute the keys such that for every group of ${k-1}$ users there is a lock that they do not have the key for.

This solution easily extends to the first problem. Let the data file be $x \in \mathbb{F}_q$. Now generate ${n \choose {k-1}}$ random variables $R_i, i \in \{1, \ldots, {n\choose {k-1}}\}$ and give each user the information $x + \sum_{i=1}^{n \choose {k-1}} R_i$. Now, the values of the random variables can be distributed like the keys of the lock in the previous puzzle, and we are done.

Solution2:

This is the solution proposed by Adi Shamir (the guy behind Bitcoins), here.

Basic Idea : If you are given any $k$ points of a $k-1$ degree polynomial $f(x)$, you can determine the polynomial. So,

secret := polynomial coefficients
user data := $n$ points of the polynomial

Ofcourse, the polynomial is over a finite field. You need only $k$ random variables in this scheme to share one bit ($a_0 = [x^0] f(x)$) instead on ${n \choose (k-1)}$ in the previous scheme.












Saturday, July 20, 2013

A chess post

To improve one's chess play, reading books and famous games is an established but boring way to improve your skill. So I have resorted to playing continuously instead  which is far more entertaining but also far slower. Since the last month I started playing I have played 500 (!!) 10 min games on chess.com .

Occasionally I look at famous games. My amateur chess expert has advised me to look at the games of Paul Morphy first. I started looking at the games but then I realized that although improving is only possible when you analyze games, it is far more rewarding and easier to analyze your own games. I played this interesting chess game  recently. I am going to analyze my own and my opponent's mistakes from the principles I have gathered. Please post improvements/suggestions in comments.

Also since its turning out to be very difficult to include a dynamic chess board on blogger, I am just including the link to the game here : game?id=561308873 .

I am playing white in the above game. The winner makes the last mistake here, as always.

Black's second move seems intimidating. The bishop on b4 pins my d4 pawn. I don't know what the best defense to this is, so I move my knight and hope to quietly slip my bishop in d2 as in move 5. (I don't want the bishop to take my knight and destroy my pawn structure).

Normal development follows till move 9. White's 9. o-o is weakening. Black could have played 9. .. Bxc3, and after that 10 .. Bxe2. To defend that white should have played 9. Nd5 forking the Queen and the bishop.

Black's Queen remains on the open e-file for too long for white to play tactics such as 11. Bxa6 . Black's move 16 is also restricting. Qf5 would be better since it maintains pressure on the d4 square while providing the Queen room to move. Similarly white 17. Qe1 should have been Qe2, since it backs both the white knight and bishop.

A better move for white instead of 18. d5 would be Bd5.

Now 24. Ne5 leaves black  with little choice. The only move to protect a mate would be Qf5 or Qg5. Both of which is countered by g4.

Sunday, July 7, 2013

Experiments with Neodymium magnets

I bought a set of neodymium to play with. When you are bored, without a computer, they come in handy.

The set consisted of 216 small 4-5mm balls of magnets. The magnets came in a 6x6x6 shaped cube. That shape was very unstable and stuck to the metallic box. On trying to break apart the cube the cube disintegrated into chains.

Trying to put back the magnets into a cube is not very easy. I can say that, because my friend, a physicist, also failed at the first attempt. Here's my approach and the difficulty I face along with the tricks involved.

My approach was to create a stack of 6 rings of the spheres each ring consisting of twelve balls.
Three stacks are required to make a cube. Here what the stacks looked like.
Now I flattened out all the stacks and formed sheets of 6x6x2,
Now I just stuck the stacks together and I had my cube.


The problem

The problem was to get a stack to align properly. Actually, there are two possible ways,

Proper (left) and improper (right) alignment
The one on the left is the desired one.

Proper (top) and improper (bottom) alignment

Also all the three stacks must align properly, although you don't have to combine those stacks. Because otherwise the 6x6x2 sheets would not stick together to form a cube. One of the sheets would slide over the other similar to the bottom chains in the above figure.

The trick
Suppose you are trying to join two stacks of rings and just would not align properly. The trick is to flip one stack and then try again. There's a catch here. If both of the stacks consist of even number of rings, flipping won't work. So adding rings one by one to a stack always works.

Suppose now you have formed three stacks of rings, all properly aligned. But all the three stacks do not align properly and so you cannot stick the respective sheets together. Here, atleast two stacks must be aligning properly and the third one would not align with any of the other two. So instead of  trying to re-create the third stack ad hoc, if all the rings of the third stack are inverted, it works. 

Here's the underlying diagrams.
Magnets aligning to form rings
The spheres colored regions inside the spheres represent the north and south poles of the magnet. So if two different configurations are superimposed they align properly, otherwise flipping one of them works. 
But suppose instead of a ring we have stacks of even number of rings ( both aligned properly ), flipping does not change the configurations of the stack and hence they will always align wrong. So inverting a ring, as follows, is required.
Inverting a ring
Inverting a ring (or stack of rings)

Here are some more configurations. Interestingly, the hexagon is more stable than the cube.