Invariant Method Lecture 6: Sep 23 1234 5678 9101112 131415 1234 5678 9101112 131514.

Slides:



Advertisements
Similar presentations
Chessboard problems You don’t have to know chess to solve them.
Advertisements

Informed search algorithms
Comparative Succinctness of KR Formalisms Paolo Liberatore.
Today’s agenda 1. WASI test results 2.Quiz or HW? 3.Your stage 2 reports 4.Individual activity points.
AE1APS Algorithmic Problem Solving John Drake
Lecture ,3.3 Sequences & Summations Proof by Induction.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Introduction to Graphs
1 More Counting by Mapping Lecture 16: Nov 7. 2 This Lecture Division rule Catalan number.
1 Counting Perfect Matchings of a Graph It is hard in general to count the number of perfect matchings in a graph. But for planar graphs it can be done.
Sam Chow. One Player Games Bored MUMSians Han writes the numbers 1, 2,..., 100 on the MUMS whiteboard. He picks two of these numbers, erases them, and.
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
Mathematical Induction II Lecture 14: Nov
Prove the Impossible Sep 28 No program can check whether another program will run into infinite loop. x=0.
Recursion Lecture 18: Nov 18.
CSC 2300 Data Structures & Algorithms March 16, 2007 Chapter 7. Sorting.
Induction Lecture 5: Sep 21 (chapter of the book and chapter of the notes)
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
November 10, 2009Introduction to Cognitive Science Lecture 17: Game-Playing Algorithms 1 Decision Trees Many classes of problems can be formalized as search.
Introduction to Graphs Lecture 18: Nov 16. Seven Bridges of Königsberg Is it possible to walk with a route that crosses each bridge exactly once?
Strong Induction, WOP and Invariant Method Leo Cheung.

Invariant Method Lecture
Prove the Impossible Lecture 6: Sep 19 (based on slides in MIT 6.042)
Induction (chapter of the book and chapter of the notes)
Great Theoretical Ideas in Computer Science for Some.
Right Triangles and Trigonometry
Invariant Method
The Pigeonhole (Dirichlet’s box) Principle
Artificial Intelligence Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
Mathematical Induction I Lecture 4: Sep 16. This Lecture Last time we have discussed different proof techniques. This time we will focus on probably the.
Great Theoretical Ideas in Computer Science.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
COMPSCI 102 Discrete Mathematics for Computer Science.
A game based off of the esteemed classic By: Tadziu Kosiara.
Introduction to Graphs. This Lecture In this part we will study some basic graph theory. Graph is a useful concept to model many problems in computer.
Can you get to the treasure? You must find a path across the maze by stepping on adjacent squares. The square you move onto must be an equivalent fraction.
Matching Lecture 19: Nov 23.
1 INFO 2950 Prof. Carla Gomes Module Induction Rosen, Chapter 4.
Quiz highlights 1.Probability of the song coming up after one press: 1/N. Two times? Gets difficult. The first or second? Or both? USE THE MAIN HEURISTICS:
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 26.
1 Chapter 2 Pigeonhole Principle. 2 Summary Pigeonhole principle –simple form Pigeonhole principle –strong form Ramsey’s theorem.
Great Theoretical Ideas in Computer Science for Some.
Great Theoretical Ideas in Computer Science.
COMPSCI 102 Introduction to Discrete Mathematics.
Mathematical Induction I Lecture 5: Sep 20 (chapter of the textbook and chapter of the course notes)
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 27.
CS 173, Lecture B August 27, 2015 Tandy Warnow. Proofs You want to prove that some statement A is true. You can try to prove it directly, or you can prove.
Week 10 - Monday.  What did we talk about last time?  Combinations  Binomial theorem.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
Fifteen Puzzle Move: can move a square adjacent to the empty square to the empty square.
Some counting questions with the Rules of Chess. Chessboard and Chess pieces The game of chess is played on an 8-by-8 grid of alternately colored squares.
Induction (chapter of the book and chapter of the notes)
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Chapter 3 The Real Numbers.
Bipartite Matching Lecture 8: Oct 7.
Mathematical Induction II
9.1 Fifteen-Game (Board Game)
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Gray Code Can you find an ordering of all the n-bit strings in such a way that two consecutive n-bit strings differed by only one bit? This is called the.
More Counting A B … f Lecture 16: Nov 9.
Mathematical Games Sam Chow.
Haskell Tips You can turn any function that takes two inputs into an infix operator: mod 7 3 is the same as 7 `mod` 3 takeWhile returns all initial.
Stack Applications Lecture 29 Thu, Apr 5, /23/2019
Induction (Section 3.3).
Stack Applications Lecture 29 Thu, Apr 1, /29/2019 Stacks.
Induction Rosen 5 Lecture 8: Oct 29, 30.
CheckerBoard Square 1 has 8 Row of Squares Dark Square Light Square 1
Presentation transcript:

Invariant Method Lecture 6: Sep

Domino Puzzle An 8x8 chessboard, 32 pieces of dominos Can we fill the chessboard?

Domino Puzzle An 8x8 chessboard, 32 pieces of dominos Easy!

Domino Puzzle An 8x8 chessboard with two holes, 31 pieces of dominos Can we fill the chessboard? Easy!

Domino Puzzle An 8x8 chessboard with two holes, 31 pieces of dominos Can we fill the chessboard? Easy??

Domino Puzzle An 4x4 chessboard with two holes, 7 pieces of dominos Can we fill the chessboard? Impossible!

Domino Puzzle An 8x8 chessboard with two holes, 31 pieces of dominos Can we fill the chessboard? Then what??

Another Chessboard Problem ? A rook can only move along a diagonal Can a rook move from its current position to the question mark?

Another Chessboard Problem ? A rook can only move along a diagonal Can a rook move from its current position to the question mark? Impossible! Why?

Another Chessboard Problem ? 1.The rook is in a red position. 2.A red position can only move to a red position by diagonal moves. 3.The question mark is in a white position. 4.So it is impossible for the rook to go there. Invariant! This is a simple example of the invariant method.

Domino Puzzle An 8x8 chessboard with two holes, 31 pieces of dominos Can we fill the chessboard?

Domino Puzzle 1.Each domino will occupy one white square and one red square. 2.There are 32 blue squares but only 30 white squares. 3.So it is impossible to fill the chessboard using only 31 dominos. Invariant! This is another example of the invariant method.

Invariant Method 1.Find properties (the invariants) that are satisfied throughout the whole process. 2.Show that the target do not satisfy the properties. 3.Conclude that the target is not achievable. In the rook example, the invariant is the colour of the position of the rook. In the domino example, the invariant is that any placement of dominos will occupy the same number of blue positions and white positions.

The Possible We just proved that if we take out two squares of the same colour, then it is impossible to finish. What if we take out two squares of different colours? Would it be always possible to finish then? Yes??

Prove the Possible Yes??

Prove the Possible The secret.

Prove the Possible The secret.

Fifteen Puzzle Move: can move a square adjacent to the empty square to the empty square.

Fifteen Puzzle Initial configuration Target configuration Is there a sequence of moves that allows you to start from the initial configuration to the target configuration?

Invariant Method 1.Find properties (the invariants) that are satisfied throughout the whole process. 2.Show that the target do not satisfy the properties. 3.Conclude that the target is not achievable. What is an invariant in this game?? This is usually the hardest part of the proof.

Hint Initial configuration Target configuration ((1,2,3,…,14,15),(4,4)) ((1,2,3,…,15,14),(4,4)) Hint: the two states have different parity.

Parity Given a sequence, a pair is “out-of-order” if the first element is larger. For example, the sequence (1,2,4,5,3) has two out-of-order pairs, (4,3) and (5,3). Given a state S = ((a1,a2,…,a15),(i,j)) Parity of S = (number of out-of-order pairs + row) mod 2 row number of the empty square More formally, given a sequence (a 1,a 2,…,a n ), a pair (i,j) is out-of-order if i a j.

Hint Initial configuration Target configuration ((1,2,3,…,14,15),(4,4)) ((1,2,3,…,15,14),(4,4)) Clearly, the two states have different parity. Parity of S = (number of out-of-order pairs + row) mod 2

Invariant Method 1.Find properties (the invariants) that are satisfied throughout the whole process. 2.Show that the target do not satisfy the properties. 3.Conclude that the target is not achievable. Invariant = parity of state Claim: Any move will preserve the parity of the state. Proving the claim will finish the impossibility proof. Parity is even Parity is odd

Proving the Invariant Claim: Any move will preserve the parity of the state. Parity of S = (number of out-of-order pairs + row) mod 2 ???? ?a? ???? ???? ???? ?a? ???? ???? Horizontal movement does not change anything…

Proving the Invariant Claim: Any move will preserve the parity of the state. Parity of S = (number of out-of-order pairs + row) mod 2 ???? ?ab1b2 b3?? ???? ???? ?b1b2 b3a?? ???? Row number has changed by 1 To count the change on the number of out-of-order pairs, we can distinguish 4 cases, depending on the relative order of a among (a,b1,b2,b3).

Proving the Invariant Claim: Any move will preserve the parity of the state. Parity of S = (number of out-of-order pairs + row) mod 2 ???? ?ab1b2 b3?? ???? ???? ?b1b2 b3a?? ???? Row number has changed by 1 Case 1: when a is largest, then the number of out-of-order pairs will decrease by three, and since the row number is changed by one, the parity is still the same.

Proving the Invariant Claim: Any move will preserve the parity of the state. Parity of S = (number of out-of-order pairs + row) mod 2 ???? ?ab1b2 b3?? ???? ???? ?b1b2 b3a?? ???? Row number has changed by 1 Case 2: when a is the second largest, then the number of out-of-order pairs will decrease by one, and since the row number is changed by one, the parity is still the same. (The remaining case analysis is the same.)

Proving the Invariant Claim: Any move will preserve the parity of the state. Parity of S = (number of out-of-order pairs + row) mod 2 ???? ?ab1b2 b3?? ???? ???? ?b1b2 b3a?? ???? If there are (0,1,2,3) out-of-order pairs in the current state, there will be (3,2,1,0) out-of-order pairs in the next state. Row number has changed by 1 So the parity stays the same! We’ve proved the claim. Difference is 1 or 3.

Fifteen Puzzle Initial configuration Target configuration Is there a sequence of moves that allows you to start from the initial configuration to the target configuration?

Fifteen Puzzle Initial configuration Target configuration Number of out-of-order pairs = 0 Row of empty square = 4 Parity is even. Number of out-of-order pairs = … + 1 = 14(13)/2 = 91 Row of empty square = 4 Parity is odd. Impossible!

Fifteen Puzzle If two configurations have the same parity, is it true that we can always move from one to another? YES, good project idea.

K=4 x=0 Remember the checker game that we have seen before? This can also be solved by the invariant method (with some very clever ideas).