1 / 53

Induction

Induction. Induction. Induction is the name given to a problem solving technique based on using the solution to small instances of a problem to solve larger instances of a problem. In fact we can solve problems of arbitrary size. Size.

maylin
Download Presentation

Induction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Induction

  2. Induction • Induction is the name given to a problem solving technique based onusing the solution to small instances of a problem to solve largerinstances of a problem.In fact we can solve problems of arbitrary size.

  3. Size • We need to measure the "size" of an instance of a problem.E.g. with matchstick problems, we might call the size the number of matches.It is not always obvious what the size should be for some types of problems.We will see some examples later.The size must be non – negative i..e whole numbers 0, 1, 2, …We call these numbers "natural numbers", as they are naturally usedfor counting.

  4. Zero Note that some mathematicians do not include 0 in the natural numbers.There are good reasons why we should include 0.Zero has important significance in maths (and the history of maths).One reason in when counting the size of sets, the null set is definedto have size of 0.We shall see examples of including 0 later.

  5. Two step process. • Two step process.We solve the problem in two steps.First we solve the problem instance of size 0 (not size 1).This is usually very easy (often called trivial).Second, we show how to solve, a problem of size n+1 (where n is anarbitrary natural number), given we have a solution to a probleminstance of size n.i.e. we can solve problems of a size greater by 1.The first step is called the base case of the basis of induction.The second step is the induction step.

  6. Sizes 0, 1, 2, … • By this process, we can solve problems of size 0.We also know how to solve instances of size 1 (as it is one larger than 0)We can apply the induction step to solve problems of size 2 and so on.i.e. the induction step allows us to solve problems of size onegreater than the current size problem.By repeating this process we can solve problems of any size.

  7. Problem statement – cutting the plane. • Straight lines are drawn across a sheet of paper, dividing the paper upinto regions.Show that it is possible to colour each region black or white, so thatno two adjacent regions have the same colour.(draw the scenario on board) p86 of book.

  8. Outline • The number of lines can be the size of a problem.We have to show how to solve the problem when there are zero lines.We have to show how to solve a problem when there are n+1 lines,assuming we can solve the problem with n lines.Let us call the situation when no two adjacent regions have the samecolouring "a satisfactory colouring"

  9. Zero case (base case) • This is trivial.With 0 lines, there is one region.This can be coloured black or white and will be a satisfactory colouring.

  10. Induction step • Assume a number of lines are drawn on the paper, and the regions havea satisfactory colouring.Now add an additional line (draw on board).This will divide some existing regions into two new regions,Which will have the same colour, therefore the colouring is not satisfactory. The task is to show how to modify the colouring so that it doesbecome satisfactory.

  11. The key, or the trick. • The key, or the trick.Inverting any satisfactory colouring will also give a satisfactory colouring.i.e. changing black regions for white, and vice versa will also givebe satisfactory)Let us call the two sides of the new line left and right.Inverting colours in either region will still give a satisfactorycolouring in that half (left or right).Hence, inverting the colours in one half will guarantee a satisfactorycolouring for the whole piece of paper.

  12. Non- deterministic • The algorithm for colouring is non deterministic in several ways.1.      the initial colouring is not specified (could be black or white).2.      the ordering of the lines is unspecified (a bit like theabstraction stage with the chocolate bar).3.      the naming of the left and right regions is not specified (symmetry).This mean the final colouring can be arrived at in different ways, butit is guaranteed to be satisfactory.

  13. Triominoes – problem statement. • A square piece of paper is divided into a grid of size 2^n by 2^n,where n is a natural number. Individual squares are called gridsquares. One grid square is covered. A triomino is an "L" shape madeof 3 gird squares. Show that it is possible to cover the remaining gridsquares.Try this yourself if you like.

  14. Size and Base case • The obvious size is n.The base case is when n=0, and the grid has size 1 by 1.This square will of course be covered.The base case is solved.

  15. Inductive Step • Given a gird of 2^(n+1) by 2^(n+1).Given that we know how to cover a 2^n by 2^n grid,how do we use this to help us cover a gird size larger by one.We make the inductive hypothesis that this is possible.

  16. The key • A grid of size 2^(n+1) by 2^(n+1) can be divided into 4 girds of size2^n by 2^n.By drawing horizontal and vertical lines.These 4 regions can be called bottom-left, bottom-right, top-left andtop-right.One square is already covered,We may assume this is bottom left – why?

  17. Induction 2 The bottom left grid is of size 2^n by 2^n, of which one square hasalready been covered.By the induction hypothesis, the remaining square in the bottom-leftgrid can be covered.This leaves us having to cover the remaining 3 grids. None of these have any squares covered.We can apply the inductive hypothesis if just one of the squares ineach of the 3 remaining grids is covered.This can be done by placing a triomino at the junction of the 3 grids.This tells us how the task can be done.

  18. If 1 was the base case. • What if we had chosen n = 1 to be our base case?This is also easy to do. How?However, our proof has then left out the 0 case, so we would stillneed to prove that separately.However including 0 provides a slightly deeper insight."Humans" start counting at 1,Computer Scientists and mathematicians start counting at 0

  19. 6.4 Looking for patterns • Induction used in experimental sciences, refers to the process ofgetting general laws by collecting a set of observed data (think ofNewton and Galileo)In simple terms, induction is about looking for patterns.

  20. Laws of Nature • Laws based on the process of observation introduce new knowledge.In experimental sciences, these laws are only probably true.They are tested by prediction and discarded if the predictions are false.

  21. Deduction • In contrast, deduction in the process of inferring laws from existing laws.Deductions are guaranteed to be true provided the laws on which theyare based are true.(and the deductive process is sound).These laws add nothing new, in some sense, and are simplyreformulations of existing laws (can you think of any examples).

  22. Mathematical Induction • Mathematical induction is a combination of induction and deduction.It is a process of looking for patterns, making a conjecture about patterns,And then testing if the conjecture can be deduced from existing knowledge.Guess and verify is a summary of mathematical induction.Guessing the formula is a conjecture.Verification is the process of deducing if the guess is correct.

  23. Matchsticks again • Remember the game where we could remove 1 or 2 matches.We "discovered" that piles containing 0, 3, 6, matches are losing positions.Other positions (1, 2, 4, 5, 7, 8) are winning positions.There seems to be a pattern.Losing positions are a multiple of 3, winning positions are not.This is a conjecture about all positions from observations made onjust 9 positions.We can verify this conjecture by using mathematical induction.

  24. Size • We could measure size by the number of matches.Let us measure size as the number of matches divided by 3, roundeddown to the nearest natural number.i.e. a pile of 0, 1, 2 has size 0; a pile of 3, 4, 5, has size 1The inductive hypothesis therefore is, a pile of 3n matches is alosing position, and a pile of 3n+1 or 3n+2 is a winning position.

  25. Basis • The base case for induction is when n equals 0.A pile of 0 matches is a losing position. i.e. we cannot move.A pile of 1 or 2 matches is a winning position.

  26. Inductive step • We assume a pile of 3n matches is a losing position,And a pile of 3n+1 or 3n+2 matches is a winning position.We have to show that a pile of 3(n+1) matches is a losing position,And a pile of 3(n+1) + 1 or 3(n=1) + 2 is a winning position.

  27. Argument 1 • Suppose there are 3(n+1) matches.If we remove 1 or 2 matches, we leave 3(n+1) -1 or 3(n+1) -2 behind.i.e. leaving 3n+2 or 3n+1 which are wining positions.Hence 3(n+1) is a losing position.

  28. Argument 2 • Suppose there are 3(n+1)+1 or 3(n+1)+2.By taking 1 match in the first case and 2 in the second case,This leaves 3(n+1) matches which is a losing position!Hence, 3(n+1)+1 or 3(n+1)+2 are both winning positions.

  29. 6.5 The need for proof • It is vital, when using induction, that a conjecture is properly verified.It is tempting to generalize from a few cases, to form a conjecturewhich is not true.Give the example of Fermat’s last theorem – when do we stop testing?There is definitely a need for rigorous proof.Set the dividing circle as an exercise.

  30. Dividing a circle • Draw the diagram.Given n points on the circumference of a circle,Chords are drawn between points, forming regions.The points are chosen so crossing points are distinct.How many regions does the connecting lines divide the circle.

  31. Number of portions • The number of portions is 1, 2, 4, 8, …Suggesting, in general 2^(n-1)For n=5, we get 16,However for n=6 we get 31, did we miscount?

  32. Where did we go wrong • We should have begun with n=0.But this would give us ½ regions!This does not make sense.Also the case where n=6 is an exception, WHY?

  33. Correct formula. • The correct formula is difficult to prove, but is here for the sake ofcompleteness. (n^4 -6n^3+23n^2-18n+24)/24This sequence is 1, 2, 4, 8, 16, 31, 57, 99, 163, 256, 386Just out of interest, how would you attempt to prove this?How would you write a Java program to model the adding of an extra point?

  34. 6.6 From Verification to Construction • In maths texts, induction is often used to verify formula.Verification is fine once we have a formula to verify,But we need a formula to verify in the first place.Induction in computer science is a fundamental principle in theconstruction of computer programs.

  35. Sum kth powers. • We want to sum the kth power of the first n natural numbers.The formula is (S.n denotes a function)S.n = 1 + 2 + 3 + …+ n = ½ n(n+1)We can also do squares and cubes.Verification is good if we know the answer, but what if we do not knowthe answer.

  36. Creative Process • Constructing solutions to non trivial problems involves a creative process.This means some "guess work" and intelligent input if required,And trial and error cannot be completely eliminated.However, we can reduce the amount of guesswork by replacing it bymathematical calculation.I imagine that there is no general method or algorithm to solve thisproblem in general.And I can think of cases where it is impossible. Can you?

  37. Closed Formula • Closed FormulaWe can use induction to construct closed formulae for summationsThe idea is to find a pattern, formulate it mathematically, and thenverify the pattern.Zero case. Of course we should also consider the 0 th case.(can you write this down?)

  38. Guesswork • For the sum of 4th powers, we may guess the closed formula is of theform of a 5th degree polynomial (called a quintic). We then useinduction to calculate the coefficients.This calculation is quite long, so let us just consider 1st powers.You may already know how to derive this formula,But please be patient, as this is just an illustration.

  39. Conjecture • ConjectureWe make the conjecture that the required form is a 2nd degreepolynomial (call a quadratic) a+bn+cn^2 and then calculate thecoefficients a, b, c.S.n = 1 + 2 + … + nS.n means the sum of the numbers up to n.P.n is the propositionS.n = a + b.n + cn^2

  40. Calculation of a • P.0{definition of P}S.0 = a + b.0 + c.0^2{S.0 = 0 i.e. the sum of an empty set of numbers is zero}0 = aThus, the base case has allowed us to deduce that a=0.We make the inductive hypothesis that (n<=0 && P.n ) == true.

  41. Calculation of b and c • Calculation of b and cP.(n+1){definition of P, a = 0}S.(n+1) = b(n+1) + c(n+1)^2{S(n+1) = S.n + n + 1}S.n + n + 1 = b(n+1) + c(n+1)^2{S.n = b(n) + c(n)^2}b.n + cn^2 + n + 1 = b(n+1) +c(n+1)^2{arithmetic}Cn^2 + (b+1)n + 1 = cn^2 + (b+2c)n + b + c{compare coefficients of powers of n}c=c && b+1 = b+2c && b + c{arithmetic}½ = c && ½ = b

  42. Summary • Thus 1 + 2 + …+ n = 0 +  ½ n + ½ n^2We can see how to calculate sums of other powers from this.The steps are1.      postulate a summation is a polynomial in n with degree m+12.      use induction with the fact S.0 = 0 and S.(n+1) = S.n + (n+1)^m, todetermine a system of simultaneous equations in the coefficients.3.      Finally solve the system of equations.

  43. Remark • In the case of 1st powers, there is an easy way to do this.Can you do it?It can also be interpreted graphically.

  44. Fake coin detection Introduction • Suppose we are given a number of coins, each identical, at most one isfake and the others are genuine.All genuine coins have the same weight,And the fake coin has a different weight from the genuine coins.How can we use a pair of scales to detect the fake coin?This problem is not well defined!!! (think about the business students)

  45. Problem formulation • There are 3 possible outcomes when a pair of scales is used;The scales may tip left or right or balance.With n comparisons, there are 3^n different outcomes.Given m coins, there are 1+2m possible outcomes.1 possibility is all coins are genuine.There are 2 ways each of the m coins can be fake.1+2m = 3^nIf the number of coins m, is greater than ½ (3^n -1), it is impossibleto find a fake coin if it exists.

  46. Conjecture • Given  ½ (3^n -1) coins (of which at most one is fake), it is possibleto identify the fake coin, if it exists, using at most n comparisons.n=0, the conjecture is Jtruen=1, the conjecture is false!! If we have one coin, how can we tell ifit is genuine or not, we have nothing to compare it with.

  47. Modify conjecture. Additional coin • Let us modify our conjecture,Assume we have an additional reference coin, that we know to be genuine.The problem is to construct an algorithm, which will identify the fakecoin (if it exists), or determine all the coins are genuine.

  48. 6.7.2 Problem solution basis • With 0 comparisons, we know all the coins in a collection of ½ (3^0-1)are genuine,The base case, n=0 is solved.

  49. Inductive step • Let c.n denote ½ (3^n – 1).By induction, we may assume that a fake coin (if it exists), can befound among c.n coins using a maximum of n comparisons.We have to show how to find a fake coin among c(n+1) coins using atmost n+1 comparisons.

  50. First Comparison 1 • To be able to gain any information from a comparison,The number of coins on the left and right scales must be the same.If the scales balance, then none of the coins on the scales is fake.We can then discard these coins, and look at the coins on the table.Hence c.n coins must remain on the table as c.n is the maximum numberof coins among which a fake coin could be detected with n comparisons.

More Related