Title: On Mathematical Contents of Computer Science Contests
1On Mathematical Contentsof Computer Science
Contests
- Nikolay V. Shilov
- (Computer Science at KAIST Mathematics and
Mechanics at Novosibirsk State University,
Russia) - Svetlana O. Shilova
- (Novosibirsk Institute of Mathematics, Russia)
2Science Contests and Olympiads
- Science Olympiads and contests brings
spirit of competitiveness to
Science education. They
benefit best students, engage
them with research, recruit new
talented researchers and engineers. - Simultaneously Science Olympiads
and contests challenge faculty
to enhance teaching
so that regular
student can enjoy Olympiad problems.
3Situation with Computer Science Contests
- Computer Science contests become very popular
with undergraduate students. Simultaneously they
become more similar to a technical sport than to
Science Olympiad. - Three corner-stones of a success in these
contests are - art of problem formal modeling,
- cooking book of algorithms in heads,
- rapid typing skills in hands.
4Situation with Computer Science Contests
- The art of modeling is especially important since
it is about research (not about technical
proficiency), it puts Computer Science contests
in line with science Olympiad like Mathematics
and Physics Olympiads. - Research component in Computer Science is not
limited by art of modeling. It includes formal
mathematical proofs of model properties and
program correctness. Without proofs, a utility of
some programs is very conventional (in spite of
extensive testing).
5Situation with Computer Science Contests
- We discuss a particular problem that fits
Mathematics Olympiad and Computer Science
contests format simultaneously. But there is a
number of other Computer Science problems that
fit contest format, and that extend Computer
Science by interesting Mathematics. - Some of these problems can become student
research topics and can help to overcome
alienation when Computer Science students
consider Mathematics being too pure, and
Mathematics students consider Computer Science
being too poor.
6Sample Problem I Balancing Coins
- Math All valid coins have equal standard weight,
a fake - coin has another weight. Is it possible to
identify a unique - fake in a set of 13 coinsbalancing them 3 times
at most?
- Comp. Sci Write a program that inputs a number
of coins - M and balance limit N and outputs
- impossible, if it is impossible to identify a
unique fake in set of M coins balancing them N
times - an executable program that implements a scenario
for fake coin identification otherwise.
7Sample Problem II Black and White vs. Mars
Mission
- Math There are N black and N white points on the
plane, - non three are collinear. Prove that it is
possible to couple - black and white points in 1-1 manner by intervals
without - intersections.
- Comp. Sci There is a number of robots in a
crater on Mars and - the same number of shades. It is state of a sandy
storm alarm. - Every robot has no obstacle to move to every
shade directly by a - straight line. To exclude collisions,
intersections of routes are - prohibited. Write a program that inputs positions
of robots and - shades and then assigns individual shade for
every robot.
8Mathematics solves Mars Mission Problem
- Geometric model for Mars Mission is a set of N
black and N - white points on the plane without collinear
triples. - Mathematical approach to Mars Mission problem
consists - in the following steps
- proving existence of any intersection-free
coupling - extracting algorithm from existential proof
- implementing the algorithm.
- Proving and algorithm engineering are research
- components, but testing of implementation can not
assess - neither proving nor originality of algorithm.
9Computer Science solves Mars Mission Problem
- But one can think about pure Computer Science
approach - to Mars Mission problem.
- There are two (at least) choices for algorithm
design - without preliminary proving of model properties
- exhaustive search,
- heuristic search.
- Let us examine both at some extend...
10Computer Science solves Mars Mission Problem
- The most stupid exhaustive search can be
described at - informal level as follows
- In this informal algorithm coupling is any set
of N intervals - that couples black and white points in 1-1
manner, a good - coupling is a coupling without intersections.
The algorithm - is too inefficient, since it obligatory generates
and stores all - possible N! couplings. Termination is guaranteed,
but - termination with good coupling is not
guaranteed-(
- input initial positions of BW points
- generate and store all couplings for BW points
- search a good coupling among generated.
11Computer Science solves Mars Mission Problem
- Improved exhaustive search algorithm can be
described at - informal level as follows
- The improved algorithm avoids storage of all
possible - couplings. It exploits abstract data type
(coupling) and - standard structured control constructs (while
loop). - Termination guaranties correctness (i.e. that a
good - coupling is found), but termination is not
guaranteed-(
VAR X coupling Xinitial WHILE not good(X)
DO X next(X)
12Computer Science solves Mars Mission Problem
- The idea of the heuristic search for Mars Mission
is trivial - start with initial coupling and try to resolve
local conflicts - (i.e. eliminate local intersections).
- This idea can be represented as follows
- where flip is operation that finds some
intersection (if any) - in the coupling and switches it off.
VAR X coupling Xinitial WHILE not good(X)
DO Xflip(X)
VAR X coupling Xinitial WHILE not good(X)
DO Xnext(X)
13Computer Science solves Mars Mission Problem
?
flip
(Flip eliminates an intersection, but may
introduce several new!)
14Computer Science solves Mars Mission Problem
?
flip
?
flip
For the initial coupling depicted above the
heuristic search algorithm terminates in 3
steps.
?
flip
15Computer Science solves Mars Mission Problem
- The design of heuristic search algorithm is based
on a - naïve believe that local improvements can solve
the - problem. Termination of the algorithm guaranties
that a - good coupling is found. But termination is not
guaranteed
flip
2nd interval
2nd interval
1st interval
1st interval
flip
16How Computer Science Proves Algorithm Termination
- Method of R. Floyd
- A well-founded set (WFS) is a partial order (D,?)
without infinite decreasing sequences d1 gt d2 gt
... - Assume that F is a total mapping from
configurations of a program into WFS (D,?). - If algorithm precondition guarantees that each
loop iteration decreases the value of the
function F, then it guarantees program
termination.
17Heuristic Search How to Prove Termination
- For given N black and given N white points on the
plain - there exist N! different couplings. In
particular, all possible - 6 coupling for given 3 black and given 3 white
points are - depicted below by different colors.
1
5
2
4
6
1
2
6
2
3
5
3
1
1
3
4
3
5
1
4
2
2
6
3
18Heuristic Search How to Prove Termination
- For every coupling X, let F(X) be the sum ?X of
length of all - intervals in the coupling. For given black and
white points - let D be ?X X is a coupling ?R. Let ? be
standard - linear order on R. Then (D, ?) is WES (since D is
finite). - (In particular, there are at most 6 different
values ??X1, - ?X2,??X3,??X4,??X5 and ??X6 in the example above.)
1
5
2
4
6
1
2
6
2
3
5
3
1
1
3
4
3
5
1
4
2
2
6
3
19Heuristic Search How to Prove Termination
- It remains to remark that every application of
flip - to two intersecting intervals that are not on a
- straight line decreases the value of F due to
the - triangle inequality
- gt
- Hence the loop WHILE not good(X) DO Xflip(X)
- always terminates, if there is no collinear
triples!
d
3
1
a
b
2
4
1
2
3
4
b
a
d
c
d
a
b
c
c
20Computer Science solves Mathematical Problem
- It implies that heuristic search algorithm
- always terminates with good coupling, if there
are no - collinear triples. It also implies that we solve
the following - mathematical problem
VAR X coupling Xinitial WHILE not good(X)
DO Xflip(X)
There are N black and N white points on the
plane, non three are collinear. Prove that it is
possible to couple black and white points in 1-1
manner by intervals without intersections.
21Conclusion
- Observe that
- without proof the heuristic search algorithm has
a very doubtful value - the proof is mathematically strict but Computer
Science in nature. - Unfortunately, Computer Science contests do not
take - proofs in to account
22Conclusion
- But we would like to hope that Mathematics and
Computer - Science faculty can work together toward
- better Mathematics Contents of Computer
- Science Contests. We do believe that it
- enhance Mathematics and Computer
- Science university teaching.