Group action

Targil 10 –algorithms
1. A road in desert area is a real line with camps at integer points. It is a day’s walk
between two camps. A human can carry 3 packed lunches, while he or she
consumes one lunch each day. There is a base at 0. Things can be left only in the
camps. It is required to organize an expedition, which will leave a packed lunch at
camp 5, and all members of the expedition should return alive to the base. How
many packed lunches are required?
Answer. 243 (= 35)
Solution. Let us construct an example of expedition which consumes 243 lunches.
We shall divide the expedition into 3 equal companies. First two companies will
arrive to camp 1, place leave there 1 packed lunch each and come back.
The third company will take the lunches left by the second company and continue
with the expedition. After they shall return to camp 1, they shall take packed
lunches left by the first company and return home. So we see that if K lunches are
enough to leave a lunch at camp N, then 3K lunches are enough to leave a lunch in
camp N+1, so by induction 3L lunches are enough to leave a lunch at camp L.
A proof that in no way we can manage with less than 243 packed lunches, can be
constructed by introducing an appropriate energy function (a. k. a. semi-invariant).
Define the energy of packed lunch at camp K as 3K, and the energy of a soldier at
camp K as  3l    3  9  ...  3K  . That is precisely minus the energy required
K
l1
to bring him home, so any soldier returning home without extra supplies is
preserving the energy. The total energy is sum of energies of all lunches and all
soldiers.
If a soldier that takes 3 lunches from camp K to camp K+1 the energy of lunches
changes from 3·3K to 2·3K+1 so it goes up by 3K+1, but the energy of the soldier is
reduced by the same amount. If a soldier takes less than 3 lunches from K to K+1,
or takes less than one lunch from K+1 to K, or stays in the camp and eats a lunch,
then the energy is obviously reduced.
In the beginning of the expedition, all soldiers have energy 0, and lunches have
energy N, where N is number of lunches acquired at afsanaut. In the end, all
soldiers have energy 0 and lunch at camp 5 has energy 243. Since energy is not
growing, N is at least 243.
Remarks (1). We used 81 soldiers. In fact, we could do it with one soldier, that
would be coming back and forth many times. However, the expedition would take
months, instead of ten days.
(2) The problem can be solved “from the end”: assume that now we have a lunch at
camp 5. Before that we had a man with 2 lunches there and 1 lunch waiting for him
at camps 1, 2, 3, 4. Before that, we had a man with 4 lunches at camp 4 and one
lunch waiting for him at camps 1, 2, 3. And so on. Of course, explaining
minimality would be a mess.
2. (a) A soldier is a finite automata: his head has a finite number of states, and he
can respond to a finite number of commands. A row consists of N soldiers, which
are in the same initial state. Prove that they can be programmed so that several
seconds after the leftmost soldier will receive a specific command, they will shoot
simultaneously. Each soldier can pass a command to every neighbor during any
second.
(b)* Show that for a row of length N no more and no less than 2N – 2 seconds are
needed between the first command and the shooting, if the most efficient algorithm
is used.
Solution. (a) First, we shall explain how to find the middle. We send two signals:
one with a speed 1 soldier/sec and another with speed 1/3 soldier/sec. It means, the
soldiers get an order to pass order A on next second after receiving it, and to pass
order B on 3 seconds after receiving it. The rightmost soldier will pass the orders
back.
The two signals meet in the middle of the row. Actually, they can almost meet:
they can come with a delay of two seconds, but a soldier of finite brain can deal
with that. Also, there can be one middle soldier or two middle soldiers.
Anyway, when the signals meet in the middle, the middle soldier/soldiers decides
that he is an end-most soldier of a sub-line (or two sub-lines) who have just
received an order to organize shooting, and row splits in halves (autonomous but
synchronized).
In such case, he starts the process described above recursively.
If a signal comes back too quickly, means that halves of halves of etc. are short
enough already (say of two soldiers), the soldier orders his neighbor to shoot and
shoots the next second.
The process takes O(n) (about 3n I think) seconds to run.
(b) There is an easy way to prove that it cannot be better than 2n-2, even if soldiers
would have infinite memory and brainpower. To synchronize the shooting, the
chain should first compute its length (because the shooting time obviously depends
on the length of chain). Before soldier 0 received an order, nobody knows nothing
about the length of chain. Suppose soldier d was the first to get some indication of
chain length. It can happen only after 2n-2-d seconds, because it can only be done
after a signal from soldier 0 reached soldier n-1 and got back. Only then the
decision can be made about the moment of shooting, and the earliest possible
moment of shooting is 2n-2 because otherwise the command to shoot at that
moment won’t reach soldier 0 in time.
I don’t really know the algorithm for 2n – 2, but there are some references and
hints in wiki: http://en.wikipedia.org/wiki/Firing_squad_synchronization_problem
They claim that the optimal solution was found by Abraham Waxman in 1966 after
being an open problem for almost 10 years. I shall lay my hands on that article in a
couple of days and send it to the community.
3. Show that in Conway’s game “Life” there is a configuration without pre-image.
(The Game of Life http://en.wikipedia.org/wiki/Conway's_Game_of_Life is played on an
infinite two-dimensional grid of square cells, each of which is in one of two possible states, live or dead.
Every cell interacts with its eight neighbors. At each step in time, the following transitions occur:
1. Any live cell with fewer than two live neighbors dies, as if caused by underpopulation.
2. Any live cell with more than three live neighbors dies, as if by overcrowding.
3. Any live cell with two or three live neighbors lives on to the next generation.
4. Any dead cell with exactly three live neighbors becomes a live cell.)
First solution. Consider configurations in N×N square. They depend on the
situation in the previous moment of (N+2)×(N+2) square.
Divide the of (N+2)×(N+2) square into 3×3 tiles (one or two untiled rows and
columns may remain. A tile will be called special if it has one of the following two
configurations:
0 0 0
0 0 0
0 1 0
or
0 0 0
0 0 0
0 0 0
We shall roughly estimate number o configurations with less than K special tiles.
There are less than TK ways to choose K tiles out of T, and the probability that all
255
the tiles that weren’t chosen are not special is  T  K where  
.
256
So the probability that there are less than K special tiles is less than T K T K .
Take K = N 3/2, and see what happens for large N:
Pr  T 
K
T K
  M 4 M 
N
2 N 3/ 2

N 2 N 3/ 2
 M  M 
M3

 N
2
N 1/ 2 1

N 3/ 2

 N
2
N 1/ 2

N 3/ 2

.
4M 3
Where M  N ,   4   1. Geometric sequence is stronger than arithmetic, so
for sufficiently large M (same as sufficiently large N), the number M  M  1
where    . Therefore the probability we’ve estimated
Pr   M 
M

4M 3
 

3
M / 2 4M
  2M   N
4
2
Let us divide all configurations on (N+2)×(N+2) square into two types:
I. Those that have less than N3/2 special tiles. According to above estimation, there
are less than of 2   N those. Pre-images of those configurations, for large N,
can give not more than 1% of all possible configurations in the smaller square.
2
2
2
1 N2
1
N 2
Indeed, for large N we have 2   N 
2 because 24 N 4  N 
100
100
N
2
1
  N 16  16N  N  1600
1
Since for large n even  N 16 
.
1600
II. Second type: those that have at least N3/2 special tiles. In each special tile, the
central cell can be taken 0 or 1, and the outcome at the next stage will be the same.
3/ 2
Therefore, this configurations come in families, each family has 2 N
configurations that become the same one on the next step. So, those configurations
N 2
2
2
are pre-images of at most 2
N 2
2
2N
3/ 2
configurations. That is also no more than
1% of all possible outcomes for large N. Indeed, 2
N 2
2
2N
3/ 2
 2 N 100 because
2
 N 3/ 2
2
24 N  4 N  2
 1/100 for large N.
So, both kinds together give only 2% of configurations, and hence 98% of
configurations don’t have a pre-image.
3/ 2
Second solution (Alexey Gladkich). Consider a big square of n×n distinct squares
of size 3×3. Chance that center cell of a 3×3 square being alive after one step is
less than 50%. Denote it 21 . Therefore, number of big squares such that after a
step, center of each of the 3×3 squares is alive is 29n 1 n  28n  n .
2
2
2
2
However, number of squares (3n – 2)×(3n – 2) in which these cells are alive is
2
3n 2  n2
2
 28n 12 n4 , which is, for large n, much greater (since  n2  12n ).
2
4.* Denote C(n) minimal number of operations required to multiply a segment by n
using compass. Denote CR(n) minimal number of operations required to multiply a
segment by n using compass and ruler. Prove that C(n)/CR(n) is unbounded.
Proof. Recall that diameter of a set is the biggest distance between its points.
With compass only, the diameter can be only doubled by each action. Therefore,
logarithm of diameter grows linearly.
With compass and ruler, if you have interval 1 and d you can build also interval d2
using Thales theorem (see the picture). So, we can take squares in constant number
of operations. Therefore, we can double the logarithm of diameter, say, each then
moves.
  is only linear is O(n) while C 2  is at least 2 ,
In other words, CR 22
n
2n
n
5.** An infinitely wise but a shortsighted cockroach is trying to find the truth (on
the Euclidean plane). If he is in a distance of less than one step from the truth, he
will reach it with the next step. After each step he is told whether he got closer to
the truth. In the beginning he knows, that the truth is N steps from him.
Prove that the minimal number of steps required to find the truth is
(a) Less than N + 10 log2(N)
(b) More than N + log2(N)/10
Solution. (a) The set of potential location of the truth is a circle.
First move (in any direction) turns it into an arc of length ~ πN±2.
During next k moves, the arc can be divided into equal halves by each move.
Indeed, consider a line going through the middle point of the arc on distance ½
from the location of the roach, and step to the symmetric point w. r. t. that line.
Then we shall be told, which half plane (among the two half planes generated by
that line) contains the truth. After log 2  N  steps the location of the truth will
be limited to an arc shorter than 1. It will take no more than N+1 + log 2  N 
additional moves to arrive to the middle of that arc, and then the roach will see the
truth.
What we got here is N + 2·log2(N) + const, where const is a small number.
Actually, it can be made N + log2(N) + const, if at first stage we would arrange
steps to approximately cancel each other.
(b) Definition. During the solution, the location of truth will be denoted T. A step
from a point A to a point B will be called verification step, if the angle BAT is at
least π/3.
Obviously, a verification step reduces the distance between the roach and the truth
only by ½ at most. Indeed, if BAT is obtuse then the distance even got bigger.
Otherwise, if P is a projection of B to AT, then BT > PT = AT – AP > AT – ½.
So, it we have an algorithm of N + log2(N)/10 steps, no more than log2(N)/5 are
verifications. Otherwise, we would approach by less than log2(N)/10 during those
steps, and by no more than N – log2(N)/10 during the other steps, so we would not
arrive to the truth.
Definitions. (1) Let O be the initial position of the roach. The circle of truth is a
circle with center O and radius N.
(2) The arc of truth is an arc of the circle of truth having central angle π/3 and the
truth as middle point. The endpoints of that arc will be denoted X and Y.
Lemma. While the roach is still in the circle of radius N/2 and center O, only
verification steps can give any information concerning the location of truth within
the arc of truth.
Proof. Consider regular (equilateral) triangle TXG, such that G is inside the truth
circle. A simple computation of angles shows that OGX = 15o = GXO, so the
triangle OGX is isosceles, GO = GX =GT = TX. Since circle of radius OG passing
through G intersects the circle of truth, its radius greater than N/2.
Therefore circle with center O and radius N/2 doesn’t contain G. Since the closest
point of circle TXG to O is G, we see that circle with center O and radius N/2 don’t
intersect.
Therefore, for each point C within N/2 steps from O, TCX is less then 60o = π/3.
Similarly, for each point C within N/2 steps from O, TCY is less then π/3.
Each step among first (N – 1)/2 generates two half-planes. If that step is not a
verification, because of what we proved, X and Y are in the same half-plane as T,
and so are all the points between X and Y. QED of lemma.
Let C be the point at which cockroach first time reaches the circle of radius N/2
with center O. Since there are no more than log2(N)/5, by the moment he arrives to
C, the arc of truth will be divided by the generated pairs of half-planes no more
than log2(N)/5 times. Therefore, the arc of assumed location of truth by the move
N log2  N  / 5  N
N/2 might be at least of length
.
2

3
3N 1/ 5
Therefore, the roach’s idea of location couldn’t be better than ½ of that number.
The way that has to be done is at least OC + CT. Let Q be a projection of T to the
N
line OC. We may assume that x = QT is at least
(Although arc of circle is
2 N 1/ 5
longer than perpendicular, but the ratio between them is less than π/3).
By Pythagoras: QC  QO  N / 2  N2  x2  N / 2
2
N2 N
2
2
2
2
2
CT  x  N  x  N / 2  N 

N2  x2 
4
2
 1
x2 
1
x2 
x2  N2 x2
2
2
21
 N 1   1  2   N 1   1  2   N  


2 
 4

N
4
N
4
2N
4
2








Lemma 2. If b > a and c2 = a2 + b2 then c > b + a2/3b.
The proof is an easy exercise.
N2 x2 N x2
So, CT 

 
4
2
2 2
3N N x 2 N N3/ 5
.
 
 
2 2 3N 2
12
N N N3 / 5
N3 / 5
N
So the total way is at least OC+CT   
.
2 2
12
12
And that is much longer than we wanted.