Lecture Coursework 2 - Computing Science and Mathematics

Download Report

Transcript Lecture Coursework 2 - Computing Science and Mathematics

Lecture Coursework 2 AGAIN

Rectangle Game

• Look at proof of matchsticks A rectangular board is divided into m columns by n rows.

The area of the board is nxm.

Each player takes turns to cut the board along a line.

The smaller piece is discarded.

The game ends with a 1 by 1 board, And the player whose turn it is to move is the loser.


• • a. A move in the component game is modelled by the assignment m := n where n < m <=2n. Do not forget this is actually two statements (n < m and m <=2n) If you draw out the first few states of the game you can make a hypothesis about what are the losing states. A hint is, it is like a power of 2. In fact a big hint is given is part b of this question regarding mex numbers.

• • • • •

Winning & Losing Positions

A winning position is a position from which there is a move to a losing position. A losing position is a position from which every move is to a winning position. Thus you need to combine your conjecture about a winning/losing position with the statement that n < m <=2n, so rewrite m as your hypothesis. The trick with induction is to show the (n+1)th case in terms of the nth case. What is the “ith + 1” losing position, what the “ith” losing position?

Sum Game 1

• • • The sum game consists of two component games. Clearly if the board is square, and the opponent goes first, we can win by simply copying their move. E.g. if position (x, x), the opponent moves to (x, y) then we move to (y, y). This part of the question is about what happens when the board is not square.

Sum Game 2

• This is a sum game.

The component games are copies of the same game.

The position in a component game is given by m (a positive integer).

A move in the game is to replace m by a number n such that n < m <= 2n


• Clearly one winning strategy is the following.

If the board is square I.e. the number of rows = the number of columns Then just copy the opponents moves.

Similar to the daisy game.

But what if we are not in a position to make the board square.

In this case we need mex numbers.

• •

Mex Numbers

Draw a graph of the problem A successor is a state which we can move to from the current state.

There maybe one or more successors from the current state.

The final state has no moves, as it is the final state.

This is given mex number 0 A given state has mex number which is the smallest natural number not included in the mex numbers of the successor states.

Show diagram in my book.

What are the patterns in the mex numbers?

The strategy is to get symmetry with the mex numbers.

This is how to play the sum game.

• • • •

Mex Numbers

Complete the table in the question about mex numbers. The table is written in 4 parts, there is good reason for this. A move from the highest position in a part of the table (e.g. 1, 3, 7, 15) can only move to the same part of the table. As there is regularity in the state transition diagram, there will be regularity in the mex numbers.

• • •

Regularity In Mex Numbers

Check that there is regularity in the mex numbers. If you are really not sure you can add a few more states to confirm what you think.

If you remember from the lecture when mex numbers were introduced, the underlying graph of the state transition diagram had no regularity so we had to generate the mex numbers by hand (see figures 4.4 to 4.6 of the APS book on the shared drive).

Winning and losing positions

• A winning position is a position from which there is a losing position we can move to.

A losing position is a position from which ever position is to a winning position.

A winner always wants to push a loser to a losing position, so the loser has no choice but to push to a winning position.

Write down an inductive hypothesis about winning/losing positions.

Show the table Talk about similarities with matchstick game.

Mex Numbers 1

• The idea of mex numbers is to be able to make a move so that they are the same in both games. Thus if the mex number of the left game is 7 and the mex number of the right game is 4, then we can move the left game into a position with a mex number of 4 (and by the definition of mex numbers, this will always exist).

Mex Numbers 2

• • • If the mex numbers are the same, then we are in a losing position. In the table, in all but the last case, the left and right positions fall in different parts of the table in section b. In the last entry in the table (i.e. position (21, 19)) we can restore the “squareness” of the board by moving L19 to give a position (19, 19).

Disjunction – Or

• True when one of the pair is true (p or q) Properties Idempotence p or p = p Symmetry p or q = q or p Associativity p or (q or r) = (p or q) or r Allows us to omit parentheses Distributivity p or (q = r) = p or q = p or r Excluded middle p or not p

Golden rule 7.2

• (p or q) = p = q = (p and q) (this is a definition of and) and has equal precedence as or.

Giving one precedence over the other obscures symmetries in their algebraic properties.

The golden rule can be read in 3 different ways.

Truth table

• p q | p or q = p | p and q = q 0 0 1 0 1 0 1 0 1 1 1 1

De Morgan

• not ( p and q) = not p or not q not ( p or q) = not p and not q


• Definition of only if p <- q = p = p or q p <- q = q = p and q these are the same, via the golden rule.

Turning the arrows around

• Definition of if p -> q = q = (p or q) p -> q = p = (p and q) these are the same, via the golden rule.

If and only-if.

• • • • • • Definitions of only-if 1.


Definitions of if 1.

p -> q = q = p v q 2.

p <- q = p = p v q p <- q = q = p ^ q p -> q = p = p ^ q

Leibniz (equals for equals)

• • • • • If two expressions are equal x y, and F is any function, Then F(x) = F(y) (p=q)^q becomes p^q (p!=q)^q becomes !p^q Show via truth table.

Note that these are special cases of “equals for equals”.

Return to Knights and Knaves

• Knights tell the truth, and knaves lie Truth table of knights and knaves. P4 A says I am same type as B Is there gold on the island This is exactly the same process as before.

Formulating questions p3 my book

• You are at a fork in the road, you want to know if the gold is to the left or the right.

Let Q be the question to be posed.

The response to the question will be A = Q Let L denote, "the gold can be found by following the left fork" The requirement is that L is the same are the response to Q.

i.e. we require L=(A=Q) {but as equality is associative} (L = A) = Q So the question Q posed is L=A I.e. "is the value of 'the gold can be found by following the left fork' equal to the value of 'you are a knight'"


• • • • A says I am the same type as B Question is “is (A is a knight) = (A is the same type as B)” Get yes if B is a knight, no if B is a knave. We cannot tell anything about A

Equals for Equals p6 my book

• There are three natives A B C.

C says "A and B are both the same type".

Formulate a question, that when posed to A determines if C is telling the truth.

Let A be the statement A is a "knight".

Let Q be the unknown question.

The response we want is C (i.e. if C is true then C is a knight).

By the previous section, Q = (A=C) i.e. we replace L by C.

C's statement is A=B, so now we know C = (A=B) by equality.

So Q = (A = (A=B)) which simplifies to Q = B, so the question to be posed is "is B a knight". Show the formal working from book p 69

A B 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 1 0 1 0 1 C 0 1 0


Portia's Casket

• How do we write the portrait is in one and only one casket?

The truth of the portrait being in the gold casket is indicated by the silver inscription.

The inscriptions on the silver casket a. the inscription on the gold casket is true, if this inscription is true b. the inscription on the gold casket is false, if this inscription is true c. if the inscription on the gold casket is true, this inscription is false d. if the inscription on the gold casket is false, this inscription is false see p 8

variable names

• ig the inscription on the gold casket is true is the inscription on the silver casket is true pg the portrait is in the gold casket ps the portrait is in the silver casket.

Each of these will end up with a true/false value at the end.

Only one of pg and ps can be true.

3 Induction

The first part is to complete the table. This should give you no problems, but if you do get stuck please ask me or email me. Remember a weight 3^i can be placed on the left, right of the scales or on the table (i.e. there is a choice of 3 positions for each weight).

We only have a single weight of each of 3^i (if we had an unlimited supply of each of these weights, the problem would be trivial as 3^0 = 1, so we could weigh anything with n weights of 1 unit).

• • • • • • • • • 1 2 3 … As with all induction proofs, we need to write the n+1 case in terms of the n th case. This is given as a hint in the question i.e. ½ (3^(n+1) – 1) = ½ (3^(n) – 1) + 3^n.

If you are really stuck then you can start to build up a table of values.

n 0 ½ (3^(n) – 1) 0 weights 0 1 4 13 … 1 1,3 1,3,9 …

We can look for patterns

• • • • • • • • • • • • Weight 5 6 7 8 9 left 1,3,5 3,6 3,7 1,8 9 right 9 9 1,9 9 9 10 11 12 13 10 1,11 12 13 1,9 3,9 3,9 1,3,9 There are lots of interesting symmetries in this table, Take a while to study it.

For the inductive step

• • • • • Note that the question says divide the range of numbers into 3. For the inductive step we assume ½ (3^n – 1) < w <= ½ (3^(n+1) – 1) We can rewrite the right hand side as ½ (3^n – 1) + 3^n (this hint is given in the question). Thus we can rewrite the expression as ½ (3^n – 1) < w <= ½ (3^n – 1) + 3^n

These 3 ranges are

• • • • • • • • ½ (3^n – 1) < w <= 3^n w = 3^n 3^n < w <= ½ (3^n – 1) + 3^n These 3 separate cases cover the case above.

Now try and solve each of these cases separately.

Clearly if the number is 3^n, we can measure this directly with a single weight. The trick is when the weight is less than this number or greater than this number. Think about placing the weight 3 on the same side of the scales as 3^n or on opposite sides.