on mathematical contents of computer science contests nikolay v. shilov (computer science at kaist...

22
On Mathematical Contents of 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)

Upload: aron-chapman

Post on 22-Dec-2015

230 views

Category:

Documents


0 download

TRANSCRIPT

On 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)

Science 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.

Situation 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.

Situation 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).

Situation 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.

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.

Sample Problem I: Balancing Coins

Sample 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.

Mathematics 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.

Computer 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...

Computer 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:-(

1. input initial positions of B&W points;2. generate and store all couplings for B&W points;3. search a good coupling among generated.

Computer 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;X:=initial;WHILE not good(X) DO X:= next(X)

Computer 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;X:=initial;WHILE not good(X) DO X:=flip(X)

VAR X : coupling;X:=initial;WHILE not good(X) DO X:=next(X)

Computer Science solves Mars Mission Problem

flip:

(Flip eliminates an intersection, but may introduce several new!)

Computer Science solves Mars Mission Problem

flip

flip

For the initial couplingdepicted abovethe heuristic search algorithm terminates in 3 steps.

flip

Computer 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:

1st interval

2nd interval

1st interval

2nd interval

flip

flip

How Computer Science Proves Algorithm Termination

Method of R. Floyd:

• A well-founded set (WFS) is a partial order (D,) without infinite decreasing sequences d1 > d2 > ...

• 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.

Heuristic 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

2

2

1

3

3

1

1

1

2

2

2

3

3

34

4

4

5

5

5

6

6

6

Heuristic 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

2

2

1

3

3

1

1

1

2

2

2

3

3

34

4

4

5

5

5

6

6

6

Heuristic 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:

| |+| | > | |+| |

Hence the loop WHILE not good(X) DO X:=flip(X)

always terminates, if there is no collinear triples!

d

ba

c

ba dc da bc

1

2

3

41 2 3 4

Computer 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;X:=initial;WHILE not good(X) DO X:=flip(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.

Conclusion

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 …

Conclusion

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.