SOLUTIONS TO TAKE HOME EXAM 2 MNF130, SPRING 2010

Similar documents
Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

3. Mathematical Induction


Just the Factors, Ma am

Midterm Practice Problems

3 Some Integer Functions

8 Divisibility and prime numbers

6.3 Conditional Probability and Independence

CS 103X: Discrete Structures Homework Assignment 3 Solutions

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Solutions for Practice problems on proofs

1 if 1 x 0 1 if 0 x 1

8 Primes and Modular Arithmetic

Lecture 17 : Equivalence and Order Relations DRAFT

k, then n = p2α 1 1 pα k

Math 319 Problem Set #3 Solution 21 February 2002

INCIDENCE-BETWEENNESS GEOMETRY

The last three chapters introduced three major proof techniques: direct,

Mathematical Induction. Mary Barnes Sue Gordon

MATH 289 PROBLEM SET 4: NUMBER THEORY

Mathematical Induction. Lecture 10-11

Homework until Test #2

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

The Graphical Method: An Example

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Mathematical Induction

Reading 13 : Finite State Automata and Regular Expressions

Mathematical Induction

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

Clock Arithmetic and Modular Systems Clock Arithmetic The introduction to Chapter 4 described a mathematical system

SECTION 10-2 Mathematical Induction

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Lecture 16 : Relations and Functions DRAFT

Discrete Mathematics Problems

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Chapter 11 Number Theory

Lecture 3: Finding integer solutions to systems of linear equations

The Taxman Game. Robert K. Moniot September 5, 2003

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

1. Prove that the empty set is a subset of every set.

POLYNOMIAL FUNCTIONS

CHAPTER SIX IRREDUCIBILITY AND FACTORIZATION 1. BASIC DIVISIBILITY THEORY

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Cartesian Products and Relations

A Little Set Theory (Never Hurt Anybody)

The positive minimum degree game on sparse graphs

So let us begin our quest to find the holy grail of real analysis.

4. How many integers between 2004 and 4002 are perfect squares?

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

1(a). How many ways are there to rearrange the letters in the word COMPUTER?

Graph Theory Problems and Solutions

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

E3: PROBABILITY AND STATISTICS lecture notes

Practical Guide to the Simplex Method of Linear Programming

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, Chapter 7: Digraphs

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Quotient Rings and Field Extensions

Continued Fractions and the Euclidean Algorithm

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

SECTION 10-5 Multiplication Principle, Permutations, and Combinations

Chapter 3. Distribution Problems. 3.1 The idea of a distribution The twenty-fold way

Math 55: Discrete Mathematics

Probabilities of Poker Hands with Variations

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Collinear Points in Permutations

MATH10040 Chapter 2: Prime and relatively prime numbers

Discrete Mathematics. Hans Cuypers. October 11, 2007

Pigeonhole Principle Solutions

6.2 Permutations continued

mod 10 = mod 10 = 49 mod 10 = 9.

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

THE DIMENSION OF A VECTOR SPACE

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Automata and Formal Languages

Bayesian Tutorial (Sheet Updated 20 March)

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

Lies My Calculator and Computer Told Me

PYTHAGOREAN TRIPLES KEITH CONRAD

Vieta s Formulas and the Identity Theorem

1 Solving LPs: The Simplex Algorithm of George Dantzig

Large induced subgraphs with all degrees odd

4. CLASSES OF RINGS 4.1. Classes of Rings class operator A-closed Example 1: product Example 2:

GREEN CHICKEN EXAM - NOVEMBER 2012

Number Theory. Proof. Suppose otherwise. Then there would be a finite number n of primes, which we may

Introduction to Graph Theory

Handout #1: Mathematical Reasoning

Lecture Note 1 Set and Probability Theory. MIT Spring 2006 Herman Bennett

Answer: (a) Since we cannot repeat men on the committee, and the order we select them in does not matter, ( )

Lecture 1 Introduction Properties of Probability Methods of Enumeration Asrat Temesgen Stockholm University

SOLUTIONS TO ASSIGNMENT 1 MATH 576

Lecture 13 - Basic Number Theory.

This chapter is all about cardinality of sets. At first this looks like a

Basic Proof Techniques

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

Colored Hats and Logic Puzzles

Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

The Chinese Remainder Theorem

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014

Transcription:

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 PROBLEM 1 Do one of the following two problems: (I) Let a 1 =, a = 9 and a n = a n 1 + 3a n for n 3. Show that a n 3 n for all positive integers n. (II) In a round-robin pool tournament there are n participants. (Everyone plays exactly one game against each other participant and a pool game cannot end with a draw.) Show that no matter how the games end, it will be possible after the tournament to make a list of all players such that each player has beaten the next player in the list in the match they played against each other. SOLUTION to (I): We use strong induction on n. Let P (n) be the predicate a n 3. The base case is the case n = 1. By definition a 1 = 3 = 3 1, so that P (1) holds. In the inductive step, assume that k 1 and that P (n) holds for all n = 1,..., k. We then want to prove that P (k + 1) holds. If k =, then by definition a = 9 = 3, so that P () holds. (One could also treat this as a basis step, together with P (1)). If k 3, then by the recursive definition and the induction hypothesis, we have a k+1 = a k + 3a k 1 3 k + 3 3 k 1 = 3 k + 3 k = ( + 1) 3 k = 3 3 k = 3 k+1, so that P (k + 1) holds. the proof is thus complete. SOLUTION to (II): We use strong induction on n. Let P (n) be the predicate that in every n-player round-robin (pool) tournament where games cannot end with a draw, there exists a ranking p 1, p,..., p n of the players such that p i defeats p i+1 for all i = 1,..., n 1. In the base case n = 0, there are no players, so there is nothing to prove. Therefore P (0) trivially holds. (One may also define n = 1 to be the base case, in which case the result also holds trivially. In fact it even holds trivially for n =.) In the inductive step, assume that such a ranking exists for every tournament with up to k 0 players in order to prove that such a ranking exists in a tournament with k + 1 players. Choose an arbitrary player x. Let B(x) be the set of players that beat x and let L(x) be the set of players that lose to x. Note that any of these sets have at most k players and that either might be empty. Let b = B(x). Then 0 b k and by the induction hypothesis, there exists a ranking of the players in B(x), say p 1,..., p b such that p i defeats p i+1 for all i {1,..., b 1}. Similarly, as 0 A(x) = (k + 1) 1 b = k b k, there exists a ranking of the players in B(x), say p b+,..., p k+1 such that p i defeats p i+1, for all i {b +,..., k}. 1

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 Set p b+1 = x. Then p 1,..., p b, p b+1, p b+,..., p k+1 is a ranking of all the players. By construction, p i defeats p i+1. whenever i b, b + 1. In addition, we know that p b defeats x = p b+1 since p b B(x) and that x = p b+1 defeats p b+ since p b+ L(x). Thus, p 1,..., p b, p b+1, p b+,..., p k+1 is the desired ranking. PROBLEM (a) How many students must be in a class to guarantee that at least five were born on the same day of the week? SOLUTION: If there are N students and we group them according to on which of the seven days in a week they were born, the (generalized) pigeonhole principle guarantees that there is a day when at least N 7 were born. The answer to the question is therefore the smallest integer N such that N 7 5, which is the smallest integer N such that N 7 > 4. This means N = 7 4 + 1 = 9. (b) How many different license plates can be made if each license plate consists of three letters followed by three digits or four letters followed by two digits? (The letter can be taken from the English alphabet, which consists of 6 letters.) SOLUTION: By the product rule there are 6 3 10 3 different license plates consisting of three letters followed by three digits and 6 4 10 different license plates consisting of four letters followed by two digits. By the sum rule, the total number of different license plates is therefore 6 3 10 3 + 6 4 10 = 63 73 600. (c) You are at a family dinner, where there are nine other members of your family. You want to arrange five of the other nine persons in a row for a picture. In how many different ways can this be done, if your parents are to be in the picture, standing next to each other? SOLUTION: Ordering the persons for such a picture consists of: (i) Choosing which one of mom and dad should be on the left. ( possibilities.) (ii) Choosing which of the four possible positions the leftmost of these should occupy in the picture. (4 possibilities.) (iii) Choosing 3 persons among the remaining 7 and the order in which they should occupy the three remaining positions in the picture. (P (7, 3) possibilities.) By the product rule, the number of different ways the arrangement can be done is 4 P (7, 3) = 4 7! 4! = 1680.

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 3 PROBLEM 3 Consider the following relations on the set of positive integers: R 1 = {(x, y) gcd(x, y) = 1} R = {(x, y) x and y have the same prime divisors} (a) Check whether the relations are reflexive, symmetric, antisymmetric, or transitive. SOLUTION: R 1 is not reflexive since gcd(, ) =, so (, ) R 1. R 1 is symmetric since gcd(x, y) = 1 implies that gcd(y, x) = 1 (in fact, gcd(x, y) = gcd(y, x)). R 1 is not antisymmetric since gcd(, 1) = gcd(1, ) = 1 so both (, 1), (1, ) R 1. R 1 is not transitive since gcd(, 3) = 1 and gcd(3, ) = 1 but gcd(, ) =, so (, 3), (3, ) R 1 whereas (, ) R 1. R is reflexive since x and x have the same prime divisors, for any positive integer x. (Note that 1 does not have any prime divisors.) R is symmetric since x and y have the same prime divisors if and only if y and x have the same prime divisors. R is not antisymmetric since 1 and 18 have the same prime divisors (namely and 3) and 18 and 1 have the same prime divisors. R is transitive, for if x and y have the same prime divisors, and y and z have the same prime divisors, then also x and z have the same prime divisors. (b) Why is R an equivalence relation? What is the equivalence class of 1? Write the equivalence class of a positive integer n in the simplest way possible, using the Fundamental Theorem of Arithmetics. SOLUTION: R is an equivalence relation since it is reflexive, symmetric and transitive. The equivalence class of 1 consists only of the number 1 itself, since it is the only positive integer with no prime divisors at all. So If n is a positive integer and n, let [1] = {1}. n = p a 1 1 pan n be the unique factorization into primes, for integers a i > 0. Then [n] = [p 1 p n ] = {p k 1 1 pkn n k i Z, k i 1}. (c) What is the intersection of the two relations R 1 and R? SOLUTION: Recall that for two positive integers x and y we have gcd(x, y) = 1 if and only if they have no common prime divisors. Therefore (x, y) R 1 R if and only if x and y have the same prime divisors and simultaneosly have no prime divisors in common. Therefore, neither x nor y can have any prime divisors at all, so x = y = 1. In conclusion R 1 R = {(1, 1)}.

4 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 PROBLEM 4 Suppose that R and S are symmetric relations on a set A. Prove that R S is also symmetric. SOLUTION: Assume that (x, y) R S. Then (x, y) R and (x, y) S. Since R is symmetric it follows that (y, x) R. Moreover, (y, x) S, for if (y, x) S, we would have (x, y) S, a contradiction. Therefore, (y, x) R S, so that R S is symmetric. PROBLEM 5 Consider the poset S with the following Hasse diagram: (a) Why is S not totally ordered? Find a totally ordered subset of S consisting of 5 elements. SOLUTION: The Hasse diagram tells us that x y if and only if there is a path in the graph going from x to y by making only upward moves (straight upward or diagonally upward). We therefore see that there are several pairs of noncomparable elements, for instance a and b (since we neither have a b nor b a), or f and d, or h and k. Therefore S is not totally ordered. To find a totally ordered subset of S consisting of 5 elements, we just need to find 5 elements on top of each other, for instance {a, e, h, j, l} or {c, g, i, k, l}. (b) Find the following elements, or show that they do not exist: (i) all maximal elements of the poset; (ii) all minimal elements of the poset; (iii) the least element of the poset; (iv) the greatest element of the poset; (v) the greatest lower bound of the set {a, b, c}; (vi) the least upper bound of the set {a, b, c}. SOLUTION: (i) By definition an element M is maximal if and only if there is no element m such that M m, that is, there is no element lying above M in the Hasse diagram. Therefore, l is the only maximal element.

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 5 (ii) By definition an element m is minimal if and only if there is no element M such that M m, that is, there is no element lying under m in the Hasse diagram. Therefore a, b, c and d are the minimal elements. (iii) By definition m is the least element if m M for all M S (in particular, it must be minimal and comparable with all other elements). Since there is more than one minimal element, there is no least element. (iv) By definition M the greatest element if m M for all m S (in particular, it must be maximal and comparable with all other elements). We see that l is the greatest element. (v) There is no lower bound of the set {a, b, c}, since such an element m would satisfy m a, b, c. So there is no greatest lower bound. (vi) An upper bound of the set {a, b, c} is an element M S satisfying a, b, c M. Therefore the only two upper bounds are j and l. Since j l, we have that j is the least upper bound. (c) Use a topological sort to find a total ordering of the elements that is compatible with the partial ordering. SOLUTION: We start by picking a minimal element of the set (that is, an element at the bottom of the diagram), remove this and reiterate the process, choosing a minimal element every time. Example of total orderings we get are: a b e h c d g f i k j l and a b c d e f g h i j k l. PROBLEM 6 (a) Does a simple graph that has five vertices each of degree three exist? If so, draw such a graph. If not, explain why it does not exist. SOLUTION: The sum of the degrees is 15, an odd number, contradicting the Handshaking Theorem. Alternatively, another theorem from graph theory states that a simple graph must have an even number of vertices of odd degree. So the conclusion is: such a graph cannot exist. (b) Determine whether the following graph is bipartite or not:

6 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 SOLUTION: The graph is bipartite since the vertex set can be partinioned into {a, c, e} and {b, d, f} and all edges connect vertices in one set with vertices in the other set. (c) The picture shows the floor plan of an office. Use ideas from graph theory to prove that it is impossible to make a walk that passes through each doorway exactly once, starting and ending at A. SOLUTION: Draw a graph using vertices for rooms and edges for doorways. If a walk starting and ending at A and passing through each doorway exactly once exists, then we must exit a node every time we enter it, including starting and ending at the node A. Therefore, all nodes would have even degree. But B and D have odd degrees, so such a walk does not exist. PROBLEM 7 Consider the following program segment: i := 1 total:= 1 while i < n begin i := i + 1 total:=total+i end (a) Let p be the proposition total= i(i+1) and i n. Show that p is a loop invariant. SOLUTION: Assume that, at the beginning of one execution of the while loop, p is true and the condition i < n of the while loop holds. In other words, we assume that total= i(i+1) and i < n. Suppose that the while loop is executed again. The variable i is incremented by 1, that is, i new = i old + 1, whence i new n, as i old < n. The variable total was total old = i old(i old +1), which now becomes total new =total old + i new = i old (i old +1) + i old + 1 = (i old+1)(i old +) = inew(inew+1). Hence p is true after a new execution of the while loop and is thus a loop invariant.

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 7 (b) Use p to prove that the program segment terminates with the output n(n+1), where n is a positive integer. SOLUTION: Before the loop is entered p is true since total= 1 and 1 n. Since p is a loop invariant, the rule of inference for loop invariants implies that if the while loop terminates, it terminates with p true and with i < n false. This means that total= i(i+1) and i n are true, but we must have i n. Hence we must have total= i(i+1) and i = n, that is, n(n + 1) total =, as desired. Finally, we show that the while loop actually terminates. At the beginning of the program i is assigned the value 1, so after n 1 traversals of the loop, the new value of i will be n, and the loop terminates at that point. We have therefore proved that the program segment terminates with the output n(n+1). PROBLEM 8 (a) What is the language generated by the grammar with vocabulary {S, A, 0, 1}, where S is the start symbol and {0, 1} is the set of terminal elements, and productions S SA, S 0, A 1A and A 1? SOLUTION: The language generated is the set {01 n n Z, n 0}, with the usual convention that 1 0 = λ, the empty string. To prove this, we first note that any string 01 n, for n 1, can be derived as S SA 0A 01A 011A 01 n, whereas the string 0 is produced simply by S 0. To see that the language does not contain any other strings we note that any derivation has to start with m times the production S SA, for some integer m 0, yielding S SA m. If m is the maximal number of S SA, the only production left involving S is S 0, and the only productions involving A eventually derive a string of 1 s from A. Thus we can only obtain strings of the form 01 n. (b) Find a grammar generating the set {0 n 1 n n Z, n 0} (with the usual convention that 0 0 1 0 = λ, the empty string). SOLUTION: We can use the grammar with vocabulary {S, 0, 1}, where S is the start symbol and {0, 1} is the set of terminal elements, and productions S 00S1 and S λ. Indeed, any string 0 n 1 n can be derived by starting with n times the production S 00S1 (possibly n = 0) followed by S λ: S 00S1 00 00S1 1 0000 00S1 11 (00) n S1 n (00) n λ1 n = (00) n 1 n = 0 n 1 n.

8 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 In fact, any derivation has to consist of n times the production S 00S1 (possibly n = 0) followed by S λ, so these are the only strings generated. (c) What is the output string generated by the finite-state machine described by the following diagram when the input string is 11101? SOLUTION: Because of the input bits, the machine will go through the following states after s 0 : f(s 0, 1) = s 1, f(s 1, 1) = s, f(s, 1) = s 0, f(s 0, 0) = s, f(s, 1) = s 0, where we actually do not need the last state. Therefore, the produced output string is g(s 0, 1)g(s 1, 1)g(s, 1)g(s 0, 0)g(s, 1) = 10000. PROBLEM 9 (a) Here is an incorrect solution to a problem. Find and explain what is not correct and give the correct solution. Problem: Find the number of ways to get two pairs of different ranks (such as two jacks and two fives) in a 4-card hand from an ordinary deck of 5 cards. Solution: There are 13 ways to get a rank (such as kings ) for the first pair and ( 4 ) ways to get a pair of that rank. Similarly, there are 1 ways to get a rank (such as sevens ) for the second pair and ( 4 ) ways to get a pair of that rank. Therefore, there are ( ) ( ) 4 4 13 1 ways to get two pairs. SOLUTION: The same hand is counted twice. For example, getting the kings of hearts and diamonds first and the sevens of clubs and hearts second is the same as getting the pair of sevens first and the pair of kings second, but we have counted this as two possibilities in the reasoning. Mathematically speaking, the proposed solution counts the number of ordered pairs of different ranks. Therefore, to obtained the desired answer we must divide by two. Hence the correct answer is 1 13 ( 4 ) 1 ( ) 4 = 1 13 6 1 6 = 808.

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 9 (b) What is the probability that a 5-card hand from an ordinary deck of 5 cards contains two pairs of different ranks? (You will need the correct answer from (a). If you cannot come up with an answer to (a), just call the answer x and give the answer to (b) in terms of x.) SOLUTION: The hand consists of five cards. There are two ways that the hand can contain two pairs of different ranks: (i) The hand contains two pairs of different ranks and the fifth card has different rank from the other two; (ii) The hand contains two pairs of different ranks and the fifth card has the same rank as one of the two pairs (that is, the hand is a so called full house). The number of ways that the hand can contain two pairs of different ranks is then, by the sum rule, the sum of the number of ways to obtain (i) and (ii). The number of ways to obtain (i) is, by the product rule, the number of ways to get two pairs of different ranks in a 4-card hand times the number of ways to pick the fifth card among the 44 cards of the remaining 11 ranks. The first one is the number 808 from (a) and the second is C(44, 1) = 44. So the number of ways to obtain (i) is 808 44 = 1355. The number of ways to obtain (ii) is not simply 808 times the number of ways to pick the fifth card among the 4 cards of the same two ranks (which is C(4, 1) = 4). The reason for this is that this number counts the same hand three times: for instance, getting the two pairs kings of hearts and diamonds and seven of clubs and hearts, and then the king of clubs as the fifth card, is the same as getting the two pairs kings of hearts and clubs first, and then the king of diamonds as fifth card, and again the same as getting the two pairs kings of clubs and diamonds first, and then the king of hearts as fifth card. So the number of ways to obtain (ii) is 808 4 divided by 3, that is 1 3 808 4 = 3744. (Alternatively, this number, which is the number of ways to obtain a full house, can be counted as in Example 6 in 6.1 in the book.) So the number of ways that the hand can contain two pairs of different ranks is, by the sum rule, 1355 + 3744 = 1796. The probability is this number divided by the total number of possible combinations of 5 cards from 5, which is C(5, 5) = 5! 47!5! = 598960. So the answer is1 1796 C(5, 5) = 1796 598960 = 0.04897959. PROBLEM 10 In this problem n is a positive integer. A soccer player has n numbered footballs that he shoots against a goal. He notes with which balls he scores a goal and with which balls he does not. 1 If one interpretes the question as asking for the probability that a 5-card hand from an ordinary deck of 5 cards contains two pairs of different ranks and nothing better (that is, the hand is what is called two pairs of different ranks, and not a full house), then the answer is the number of ways to obtain (i) divided by C(5, 5), that is 1355 C(5, 5) = 1355 598960 = 0.047539016.

10 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 (a) How many different outcomes of the experiment are there? How many outcomes are there with precisely k goals, when 0 k n? SOLUTION: If he names each shot with the digit 0 if he doesn t score and with the digit 1 if he scores, then the different outcomes are all the bit strings of length n, which are in total n. The number of outcomes with k goals is the number of bit strings with exactly k 1 s. The position of k 1 s in a bit string of length n form a k-combination of the set {1,..., n}, whence the number of such strings is C(n, k). So there are C(n, k) otcomes with precisely k goals. (b) A goalkeeper tries to save the shots. He notes which shots go outside the goal, which shots go inside the goal and which shots he saves. How many outcomes of the experiment are there now? SOLUTION: We can argue similarly: Suppose the keeper still names the shots that end with a goal with the digit 1, but now divides the shots that don t end with a goal in two sets: the ones he saves, which he names with the symbol 0 S, and the ones that go outside, which he names with the symbol 0 O. Then the different outcomes are all strings of length n over the alphabet {0 S, 0 O, 1}, which are in total 3 n. (c) Let S be a set of n elements and consider the power set P (S) of S. Show that the set {(A, B) P (S) P (S) A B} contains 3 n elements. SOLUTION: (We argue as in(b).) Let S = {s 1,..., s n }. An element in the set {(A, B) P (S) P (S) A B} is determined by specifying which of the s i s are in A and which in B A (and the rest is then in S B). This can be done with the string b 1 b n of length n over an alphabet of three symbols, say {0 S, 0 O, 1}, where This means that and 1 if s i B b i = 0 O if s i B A 0 S if s i A. A = {s i S b i = 0 S }, B = {s i S b i = 0 S or b i = 0 O }. Hence the number of elements in the desired set is the number of all strings of length n over the alphabet {0 S, 0 O, 1}, which are in total 3 n. (PS: note the connection with (a) and (b): the set S consists of all n shots, the set B of all shots that don t end with a goal, and A is the subset of B consisting of all saved shots. So B A is the set of shots going outside the goal and S B is the set of goals.) (d) Give a combinatorial proof of the formula n ( ) n k = 3 n. k k=0

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 11 SOLUTION: The right hand side is the number of elements in the set {(A, B) P (S) P (S) A B}, considered in (c), or equivalently, the outcomes of the experiment of the goalkeeper in (b). Let us denote the set above by Q(S), for simplicity. Thus, we have Now consider the subset Q(S) = 3 n. Q k (S) = {(A, B) P (S) P (S) A B and S B = n k}, of Q(S), for 0 k n. (Looking back at (a) and (b), this is the set of outcomes of the goalkeeper s experiment with precisely n k goals.) An element in Q k (S) is determined by a string b 1 b n of length n over the alphabet {0 S, 0 O, 1} as in (c) with precisely n k 1 s. Such a string is determined by first specifying the positions of the n k 1 s, which gives C(n, n k) possibilities, as in (a) with k and n k exchanged, and then filling out 0 S s and 0 O s in the remaining k positions, which gives k possibilities. By the product rule, we get ( ) n Q k (S) = C(n, n k) k = C(n, k) k = k. k Clearly Q(S) is the disjoint union of all Q k (S) s, for 0 k n, so that n n ( ) n Q(S) = Q k (S) = k, k and the formula is proved. k=0 k=0 PROBLEM 11 In this problem we will develop a proof of the following theorem of Fermat: If p is a prime number, then for any integer n we have n p n (mod p). (a) Let p be a prime number. Prove first the following result using the fundamental theorem of arithmetics: If a and b are integers such that pa/b is an integer and p does not divide b, then pa/b is divisible by p. Then use this result to prove that p divides ( p k) for any integer k such that 0 < k < p. SOLUTION: Let pa/b = c Z. Then pa = cb and each of a, b and c has a unique factorization into primes, by the fundamental theorem of arithmetics. Let a = p α 1 1 pα k k, b = qβ 1 1 qβ l l, c = r γ 1 1 rγs s be the factorizations, where all p i, q i, r i s are primes. Then we can write pa = cb as: pp α 1 1 pα k k = r γ 1 1 rγs s q β 1 1 qβ l l, and by uniqueness of factorization of pa and cb, the prime p has to be one of the r i s or q i s. But p does not divide b, so p is not equal to any of the q i s. Therefore q = r i for some i, so p divides c = pa/b, as was to be proved. We now consider the second problem.

1 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 If 0 < k < p we have ( ) p = k p! k!(p k)! = p (p 1)! k!(p k)!. Now ( p k) = C(p, k) is an integer, as it counts the number of k combinations of a set with p elements. Moreover, since k!(p k)! = 1 (k 1)k 1 (p k 1)(p k) and k < p and k < p k when 0 < k < p, p cannot be a prime factor of the prime factorization of k!(p k)!. Hence p does not divide k!(p k)! and we can use the result we just proved with a = (p 1)! and b = k!(p k)! to conclude that p divides ( p k) for any integer k such that 0 < k < p. (b) Use the result from (a) and the binomial theorem to prove that, for any integers x and y we have (x + y) p x p + y p (mod p). SOLUTION: By the binomial theorem ( ) ( ) ( ) ( ) p p p p (x + y) p = x p + x p 1 y + x p y + + x y p + x y p 1 + y p. 1 p p 1 By (a) p divides each of the coefficients ( ( p 1), p ) (,..., p ) ( p, p p 1), so that whence by definition. (x + y) p = x p + y p + some multiple of p, (x + y) p x p + y p (mod p) (c) Use mathematical induction and the result from (b) to prove that n p n (mod p) for all positive integers n. (Hint: n = (n 1) + 1.) SOLUTION: The base case is the case n = 1, which follows as 1 p = 1. Now assume that n and that the result holds for n 1, that is assume that Then proving the result. n p = ( ) (n 1) p n 1 (mod p). ( (n 1) + 1) p (n 1) p + 1 p (mod p) (by (b)) (n 1) + 1 (mod p) (by (*)) n (mod p), (d) Explain why the formula you obtained in (c) is also valid if n is zero or a negative integer. (This finishes the proof of the theorem of Fermat.) SOLUTION: If n = 0, then 0 p = 0, so the result holds. Assume now that n < 0, so that n = n, where n is a positive integer, so that we can use the result from (c) on n.

SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 13 If p is odd, then n p = ( n ) p = ( 1) p ( n p ) = n p, so that (c) yields n p = n p n (mod p) (by (c)) n (mod p). If p =, then we have n n (mod ), since divides n. Hence n = ( n) n (mod ) (by (c)) n (mod ). PROBLEM 1 On a remote island lives a happy tribe. The island is so small that everybody knows everybody. The inhabitants are extremely intelligent and rational, except for the following: It is considered to be a big shame to have blue eyes. If one inhabitant discovers having blue eyes, he/she will flee from the island at midnight and never come back. Luckily there are no mirrors on the island, nobody knows genetics and everybody is too polite to talk about anybody s colour of eyes. One day a missionary comes to the island. As he is about to leave he tells everybody that he finds it strange that there are two colours of eyes in such a small community, blue and brown. On the 43rd night after this happens, many inhabitants flee from the island. How many persons were blue-eyed on the island? (Hint: use induction on the number of blue-eyed inhabitants.) SOLUTION: The answer is 43. This can be proved as follows: Assume that the number of blue-eyed inhabitants is n. We know that n 1, and so does each inhabitant in the island, as the missionary said so. We want to prove the following predicate P (n) On the n th night after the missionary leaves, all blue-eyed inhabitants flee from the island. The base case is the case n = 1. If there is only one blue-eyed person, then this person observes (as he knows everybody else on the island) that all other have brown eyes. As the missionary tells that there are two colours of eyes among the inhabitants, he immediately deduces (being intelligent and rational) that he must be blue-eyed, and so he flees the island on the first night, as was to be proved. (We need not do the case n =, but it is instructive to look at this step as well: If there are two blue-eyed persons, each of them counts one blue-eyed person among the other inhabitants, whereas all other inhabitants count blue-eyed persons. Being rational and intelligent, each of these two blue-eyed persons know that there are only two possibilities: (I) I am not blue-eyed, whence there is only one blue-eyed person on the island, which is the guy I see has blue eyes. Being intelligent and rational, he will immediately deduce he is blue-eyed by what the missionary says, and so he will escape on the first night. (II) I am blue-eyed, so there are two blue-eyed persons on the island, the other guy and myself. After the first night is over, each of the two sees that the other guy hasn t fled the island, so each of them can deduce that (I) isn t the case, so that (II) holds, and they both deduce

14 SOLUTIONS TO TAKE HOME EXAM MNF130, SPRING 010 that they are blue-eyed after the first night. Thus, the both flee the island on the second night.) Now assume that n and that P (n 1) holds. Any blue-eyed person observes that there are n 1 blue-eyed persons among the other inhabitants. Being rational and intelligent, each of the blue-eyed persons knows that there are only two possibilities: (I) I am not blue-eyed, whence there are precisely n 1 blue-eyed persons on the island. By the induction hypothesis, and since they are intelligent and rational, they will flee on the (n 1)th night. (II) I am blue-eyed, so there are n blue-eyed persons on the island. Nobody will flee on the (n 1)th night, as nobody among the n blue-eyed persons can find out for sure what the colour of their eyes is. Therefore, on the day after the (n 1)th night, each of the blue-eyed persons realize that (I) is not the case, so that (II) is the case. Thus they conclude that they are blue-eyed and flee the island on the night after, the nth night. This proves the predicate P (n). Thus, there are 43 blue-eyed inhabitants. Andreas Leopold Knutsen