Volume C1 · Basic concepts · TAOCP Section 1.2.1
Mathematical induction
Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.
Read it next to Section 1.2.1 of the book. The nodes and the exercises of the section.
Proof by induction and proofs of algorithms
Overview
Section 1.2.1 of TAOCP states the principle of proof by induction, in the form where the step from to may use all the cases . It proves two facts with it: the sum of the first odd numbers is , and the Fibonacci number is at most . It writes induction as an algorithm, Algorithm 1.2.1I, and it shows with the numbers of partitions that a pattern in small cases is not a proof. Then it turns to algorithms. It extends Euclid's algorithm of Section 1.1 so that it also finds integers and with , and it proves this Algorithm 1.2.1E by an invariant. It makes the proof a general method: put an assertion on each arrow of a flow chart and check each box. It ends with two warnings and a foundation: a proof of the assertions does not prove that the algorithm stops, and the principle of induction is the same as the fact that each nonempty set of positive integers has a least member. The section uses Section 1.1 (Algorithm 1.1E and the idea of a computational method).
The ideas
Induction proves infinitely many statements with two proofs. Let be a statement about the positive integer . To prove for all , prove , and prove that together give . Then gives , these two give , and so on: each single case has a proof of finite length. The second part may use all the earlier cases, not only . The Fibonacci bound below needs two earlier cases, and many proofs of the book need more.
A guess is not a proof. The word "induction" in the sciences means a general rule found from many cases. In mathematics, a rule that holds for can fail at . The numbers of partitions show this (Example C1.1.2.1.7 below). In this book "induction" always means proof by induction.
An invariant is induction on the steps of an algorithm. To prove that an algorithm is correct, find a relation among its variables that is true at the start and that each step keeps true. Then it is true after any number of steps, by induction on the number of steps. At the end, the relation and the stop condition together give the answer. For the extended Euclid algorithm the relations are two linear equations: each of the two current numbers is a combination of and with integer coefficients, and the algorithm keeps the coefficients up to date.
Assertions on a flow chart make this a method for any algorithm. Write a property of the state on each arrow of the flow chart. If the property on the first arrow holds for each input, and each box turns a true property on an arrow in into a true property on the arrow out, then each property holds in each run. The hard part is to find the right properties. Once they are found, the proof is a list of small checks, one for each box.
Correctness and termination are two proofs. The assertions say what is true if the run comes to a given arrow. They do not say that the run comes to the end. Algorithm 1.2.1E with real numbers instead of integers keeps all its linear invariants and can run for ever. A proof that an algorithm stops needs a quantity that gets smaller at each step in a set with no infinite decreasing sequence, such as the nonnegative integers.
C1 proves the principle of induction from the well-ordering of the positive integers, and the well-ordering from induction, so that the reader sees that the two are the same axiom. The book takes induction as the axiom and does not give the first proof. The proof of Algorithm 1.2.1E in C1 is by the invariant of eq. 1.2.1(6) and a separate proof of termination. The book also gives a second proof by induction on .
Definitions, results and proofs
Theorem C1.1.2.1.1 (the principle of induction, TAOCP Section 1.2.1). Let be a statement for each positive integer . Suppose that (a) is true, and (b) for each , if are all true, then is true. Then is true for each positive integer .
Node: TANDZ7GDS1 · status: not stated yet
Explanation. Part (a) is the base and part (b) is the step. In the simple form of induction the step uses only . The form here, often called strong induction, lets the step use all the earlier cases. The two forms prove the same statements: to get the strong form from the simple one, apply the simple form to the statement = " are all true". The book uses induction on as often as on . The change is to start the base at (exercise 1.2.1-1 is about this change). In Lean the simple form is the recursor Nat.rec and the strong form is Nat.strong_induction_on of Mathlib.
Example. Each positive integer is a sum of distinct powers of . Let be this statement. is true, since . For the step, let , suppose that are true, and let be the largest power of with . If , then is true. If not, then , since . By , the number is a sum of distinct powers of , and each of them is less than . Add to get . For : the largest power is , the case gives , and so . The step uses , not , so it needs the strong form.
Proof. The proof uses the well-ordering of the positive integers (Theorem C1.1.2.1.12 below). Suppose that is false for some , and let be the set of the positive integers for which is false. Then is not empty, so it has a least member . By (a), , so . Each of is less than , so it is not in , and are true. By (b) with , is true. This is false, since . So is empty, and is true for each .
Example C1.1.2.1.2 (the first sums of odd numbers, TAOCP eq. 1.2.1(1)). The sums of the first few odd numbers are squares:
Node: TADCCDXQPR · status: proved
The next one is . Each line is a fact that a person can check. The five lines together suggest the general rule of eq. 1.2.1(2), but they do not prove it. The proof is the next theorem.
Theorem C1.1.2.1.3 (the sum of the odd numbers, TAOCP eq. 1.2.1(2)). For each positive integer ,
Node: TAV92J4EQX · status: proved
Explanation. The sum of the first odd numbers is a square. A picture explains it: an square of cells is a square with L-shaped layers around it, and the layer that makes the square from the square has cells. The picture is a proof only when it is drawn for each , and that is the induction below. The theorem is the first example of the simple form of induction, where the step uses only .
Example. For : . For the last term is , and the sum is .
Proof. Let be the statement. For , the sum is . Suppose for some . The sum of the first odd numbers is the sum of the first , plus . By this is , which is . By the principle of induction, is true for each .
A second proof: write the sum forwards and backwards and add the two. The term meets the term , and the sum of the two is . There are such pairs, so and . This proof is not by an explicit induction, but the rule that lets a finite sum be written in a different order is itself proved by induction (Section 1.2.3).
Theorem C1.1.2.1.4 (an upper bound of the Fibonacci numbers, TAOCP eq. 1.2.1(3)). Let , and for , and let . Then
Node: TAY3BR964P · status: proved
Explanation. The Fibonacci numbers grow, but not faster than the powers of the golden ratio . The bound is the first of many facts of the book about and . Section 1.2.8 proves the exact formula , and Section 4.5.3 uses the bound to find the worst case of Euclid's algorithm. The proof needs the strong form of induction, since depends on two earlier values.
Example. The values for , with to three decimals:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | |
| 1 | 1.618 | 2.618 | 4.236 | 6.854 | 11.090 | 17.944 | 29.034 | 46.979 | 76.013 |
The bound is an equality only at , and the ratio tends to .
Proof. Let be the statement . For : . For the step, let and suppose that are true. If , then is , which is true since . If , then and give the bound of eq. 1.2.1(4), and by eq. 1.2.1(5). So , which is . By the principle of induction, holds for each .
Theorem C1.1.2.1.5 (the step of the Fibonacci bound, TAOCP eq. 1.2.1(4)). Let . If and , then
Node: TAH47VRQWJ · status: proved
Explanation. This is the core of the step of the proof of eq. 1.2.1(3). It uses two earlier cases, and it is the reason why the proof needs two base cases, and . With only the case , the step from to would need , which is true but is not part of the statement.
Example. For : and . So , and .
Proof. The equation is the rule of the sequence. Add the two given inequalities to get . The last equation is the distributive law, .
Theorem C1.1.2.1.6 (the equation of the golden ratio, TAOCP eq. 1.2.1(5)). The number satisfies
Node: TA3K7PC743 · status: proved
Explanation. The golden ratio is the positive root of . The other root is . The equation is the reason why the powers of behave like the Fibonacci numbers: multiply it by to get , the rule of the Fibonacci sequence. In Mathlib the number is Real.goldenRatio and the equation is Real.goldenRatio_sq.
Example. With : and . Also , which is the equation divided by .
Proof. .
Example C1.1.2.1.7 (the numbers of partitions, TAOCP Section 1.2.1). Let be the number of ways to write as a sum of positive integers when the order of the terms does not count. The first values are
The values are the first five primes, , so a guess from these cases is " is the -th prime". The value breaks the guess: is not prime, and the sixth prime is . To check , here are the partitions of :
The point of the example is the difference between a guess and a proof. Five correct cases make a good guess, and they are a reason to look for a proof. Only a proof for all , by induction or another method, makes the guess a theorem. Section 7.2.1.4 of the book makes all the partitions of and has much more on .
Theorem C1.1.2.1.8 (the two invariants of the extended Euclid algorithm, TAOCP eq. 1.2.1(6)). In Algorithm 1.2.1E (in the part Algorithms and programs below), each time a pass of the loop starts,
Node: TA93Q8DJED · Lean: TAOCP.S1_2_1.Eq6 (partial) · status: not stated yet
Explanation. The algorithm keeps two numbers and , which are the pair of Euclid's algorithm: they start as and , and each pass replaces by . With each of them it keeps two integer coefficients that write it as a combination of and . At the end, , and the coefficients and of are the integers and that the algorithm must find. In the notation of the book, and are and , is , and is , so the two equations are eq. 1.2.1(6) of the book.
Example. In the worked run of Algorithm 1.2.1E on , below, at the start of the third pass, and . The first invariant is , and the second is .
Proof. By induction on the number of passes. At the start of the first pass, and , so the equations are and , which are true. Suppose the equations hold at the start of a pass that does not return, with and . The pass sets the new to the old , so the new first equation is the old second equation. It sets the new to , and
So both equations hold at the start of the next pass.
The proof is exercise 1.2.1-6 in the notation of this chapter. It uses only that is an integer, and it never uses that is the remainder. This fact comes back in Example C1.1.2.1.11 below.
Definition C1.1.2.1.9 (the condition on a box of a flow chart, TAOCP eq. 1.2.1(7)). Let a flow chart have an assertion , a property of the state, on each arrow . A box of the flow chart satisfies the condition when, for each arrow into the box and each state for which is true, the box, run on , gives a state and leaves along an arrow for which is true.
Node: TAE9RB7VFA · status: not stated yet
Explanation. The condition is local: it is about one box and its arrows, not about the whole run. So it can be checked one box at a time, by algebra on the operation of the box. The arrows out of a test box have different assertions, and the condition asks for the assertion of the arrow that the test takes. The condition must hold for each arrow into the box, so a box with two arrows in has two checks, or one check with the weaker of the two assertions.
Example. Take the division box of Algorithm 1.2.1E, which sets and . Let the assertion into it be "the invariants of eq. 1.2.1(6) hold, , and ", and let the assertion out of it be the same, plus " and ". The box changes only and , so the first part stays true. Since , the division is defined and gives with . So the box satisfies the condition. The part of the assertion in is necessary: without it the division by has no meaning.
Theorem C1.1.2.1.10 (the method of assertions, TAOCP Section 1.2.1). Let a flow chart have an assertion on each arrow. Suppose that the assertion on the arrow from the start is true for each input, and that each box satisfies the condition of eq. 1.2.1(7). Then in each run, each time the run goes along an arrow, the assertion on that arrow is true of the state at that time.
Node: TAY9MWQ1B1 · status: not stated yet
Explanation. This is the general method of proof of an algorithm. It reduces a statement about all runs, which can be long, to one check for each box, which is short. The assertion on the arrow into the stop box gives the correctness: if it says "the output is the right answer", the algorithm is correct whenever it stops. The theorem says nothing about the stop itself (see Example C1.1.2.1.11). The method is due to R. W. Floyd (see the notes), and it is the base of the logic of programs that P7 teaches.
Example. The flow chart of Algorithm 1.2.1E has an initial box, a division box, a test and an update box. Let be the assertion ", , , and ". Put these assertions on the arrows:
- start to the initial box: and ;
- the initial box to the division box, and the update box to the division box: ;
- the division box to the test: , and ;
- the test to the stop, when : and divides ;
- the test to the update box, when : , and ;
- the stop: and .
The checks of the boxes: the initial box sets and , and then holds by the base of the proof of eq. 1.2.1(6). The division box is the example of eq. 1.2.1(7). The test with gives , so divides ; with it gives assertion 5. The update box gives for the new values by the step of the proof of eq. 1.2.1(6), by , and by the lemma of Algorithm 1.1E. At the stop, divides , so , and gives and . By the theorem, assertion 6 is true each time the run stops.
Proof. Number the arrows of a run in the order in which the run goes along them, and let be the state when it goes along . Let be the statement " is true". The arrow is the arrow from the start, and its assertion is true for each input, so is true. Suppose . The run goes from into a box, the box runs on , and the run leaves along with the state . Since the box satisfies the condition of eq. 1.2.1(7) and is true, is true. This is . By induction, is true for each for which the run has an -th arrow.
Example C1.1.2.1.11 (a run that keeps its assertions and never stops, TAOCP Section 1.2.1). The steps of Algorithm 1.2.1E make sense when and are positive real numbers and is still an integer. Take and . Since at each pass, at each pass, and the remainders are the powers :
| Pass | new | ||||
|---|---|---|---|---|---|
| 1 | 1 | ||||
| 2 | 1 | ||||
| 3 | 1 | ||||
| 4 | 1 |
Each step uses , which is eq. 1.2.1(5) divided by . The remainder is never , so the run never stops. But the proof of eq. 1.2.1(6) holds word for word, since it uses only that is an integer: for example , and the coefficients after pass are and . So the invariants hold at each pass of a run that does not stop. A proof of assertions proves that the answer is right if the algorithm stops, and the stop needs its own proof. For integers the stop comes from the fact that is a positive integer that gets smaller at each pass; here is a positive real number that gets smaller at each pass, and the positive real numbers have no least member. The book gives a case of the same kind with numbers , and exercise 1.2.1-12 asks for the details of that case.
Theorem C1.1.2.1.12 (the well-ordering of the positive integers, TAOCP Section 1.2.1). Each nonempty set of positive integers has a least member.
Node: TA3PJREWRP · status: not stated yet
Explanation. The book takes this as the axiom that defines the positive integers, in the form "each positive integer is or comes from a smaller one by adding , and so the integers come in order". The proof below gets it from the principle of induction, and the proof of the principle of induction above gets the principle from it, so the two are equivalent. The well-ordering is the tool for the proofs of termination: if each step of an algorithm makes a positive integer smaller, the values form a set with a least member, and the run cannot go on for ever. In Lean the least member is Nat.find, with Nat.find_spec (it is in the set) and Nat.find_min' (it is at most each member).
Example. Let be the set of the positive values of for integers and . It is not empty (), so it has a least member. The extended Euclid run below gives , so the least member is at most . Each value is a multiple of , so no positive value is less than . So the least member of is . The same argument for any and proves that the least positive value of is .
Proof. Let be a set of positive integers with no least member. Let be the statement "none of is in ". is true: if , then is the least member of , since no positive integer is less than . Suppose . If , then is the least member of , since no smaller positive integer is in by . So , and is true. By induction, is true for each , so no positive integer is in , and is empty. So each nonempty set of positive integers has a least member.
Algorithms and programs
Algorithm C1.1.2.1.13 (induction as a procedure, TAOCP Algorithm 1.2.1I). The input is a positive integer , a proof of , and a method that turns proofs of into a proof of . The output is a proof of .
Node: TAJS0SHNZM · status: not stated yet
The idea. The principle of induction is a promise: for each , a proof of exists. The algorithm makes the promise concrete. It writes the proof of , then uses the step to write the proofs of , and stops at .
The steps.
InductionProof(n): -- n >= 1
write a proof of P(1)
k := 1
while k < n:
write a proof of P(k+1) from the proofs of P(1), ..., P(k)
k := k + 1
return the last proof -- a proof of P(n)
A worked run. Take to be eq. 1.2.1(2) and . The step from is "add to both sides, and use ".
| Proof written | Statement proved | |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | , then stop |
Correctness. The invariant at the test of the loop is ", and proofs of are written". It holds the first time, with . If it holds and , the body writes a proof of from the proofs that are written, and then increases , so it holds again. When the loop ends, , so a proof of is written, and it is the last one.
Termination. The quantity is a nonnegative integer that gets smaller by at each pass, so the loop runs exactly times.
Cost. The step method runs times. If each step adds a proof of bounded length, the proof of has length . So induction gives a proof of finite length for each single case, and a short proof (the base and the step) for all cases at once. The book notes that the algorithm gives a proof of each , but that to prove that the algorithm itself works for each needs induction again. The principle cannot be proved from nothing, and that is why it is an axiom.
In Lean the procedure is the recursor Nat.rec: given the base and the step, Nat.rec gives a proof of for each , and its computation applies the step times. The Lean recursor starts at , not at .
Algorithm C1.1.2.1.14 (the extended Euclid algorithm, TAOCP Algorithm 1.2.1E). The input is two positive integers and . The output is and two integers and with .
Node: TAEDPXG0VB · Lean: TAOCP.S1_2_1.algorithmE · status: not stated yet
The idea. Run Euclid's algorithm on the pair , which starts as . With each of and , keep integers that write it as a combination of and . Each new number of Euclid's algorithm is , so its coefficients are the coefficients of minus times the coefficients of . At the end, , and its coefficients are the answer.
The steps. The pseudocode of C1 works with two triples. The triple means "", and the triple means "".
ExtendedEuclid(m, n): -- m >= 1, n >= 1
(u, x, y) := (m, 1, 0)
(v, s, t) := (n, 0, 1)
loop
q := floor(u / v); r := u - q*v -- divide
if r = 0: return (v, s, t) -- d = v, a = s, b = t
(u, x, y), (v, s, t) := (v, s, t), (r, x - q*s, y - q*t)
The last line makes both assignments at once, from the old values. The book's form of the algorithm has four steps and six variables for the coefficients, with a temporary variable for the update; the triples here hold the same values.
A worked run. Take and . Each row is the state at the start of a pass, with the and of that pass.
| Pass | ||||
|---|---|---|---|---|
| 1 | 1 | 21 | ||
| 2 | 3 | 15 | ||
| 3 | 1 | 6 | ||
| 4 | 2 | 3 | ||
| 5 | 2 | 0 |
The fifth pass returns , and . The project has no Lean definition of Algorithm 1.2.1E yet. Mathlib's Nat.xgcd computes coefficients of the same kind, and on this input it gives the same pair:
#eval Nat.gcd 99 78 -- 3
#eval Nat.xgcd 99 78 -- (-11, 14)
Correctness. Let be ", , , and ". holds at the start of each pass. The two equations are eq. 1.2.1(6), which is proved above. The rest holds at the first pass since and . At a pass that does not return, the new pair is with , and by the lemma of Algorithm 1.1E, so the rest holds at the next pass. When a pass returns, , so divides and . By , and . So the output is right. Theorem C1.1.2.1.10 above sets out the same proof as assertions on the flow chart.
Termination. The pair goes through the same values as the pair of Algorithm 1.1E on the same input. At each pass that does not return, is replaced by with , so is a positive integer that gets smaller at each pass, and the algorithm stops after at most passes.
Cost. Let be the number of passes. It is the number of divisions of Algorithm 1.1E on , so when , by the cost bound of Section 1.1 in C1. On , , and the bound is . Each pass has one division with remainder and one test. Each pass that does not return also has two multiplications and two subtractions for the coefficients. So the extended algorithm costs a constant factor more than Algorithm 1.1E and has the same order of growth. Section 4.5.2 of the book studies it again.
The exercises
The table has the exercises of Section 1.2.1. The kind is the class of spec 06.3 that C1 proposes, and the indexer of S0 fixes it in the map. The marker ▶ is the book's mark of a recommended exercise.
| Exercise | Rating | Markers | Kind | Lean | Solution |
|---|---|---|---|---|---|
| 1.2.1-1 | 05 | informal | TAOCP.S1_2_1.Ex1.solved |
X1, 1.2.1-1 | |
| 1.2.1-2 | 15 | ▶ | informal | TAOCP.S1_2_1.Ex2.solved |
X1, 1.2.1-2 |
| 1.2.1-3 | 18 | informal | TAOCP.S1_2_1.Ex3.solved |
X1, 1.2.1-3 | |
| 1.2.1-4 | 20 | K1 | TAOCP.S1_2_1.Ex4.solved |
X1, 1.2.1-4 | |
| 1.2.1-5 | 21 | K1 | TAOCP.S1_2_1.Ex5.solved |
X1, 1.2.1-5 | |
| 1.2.1-6 | 20 | K1 | TAOCP.S1_2_1.Ex6.solved |
X1, 1.2.1-6 | |
| 1.2.1-7 | 23 | K3 | TAOCP.S1_2_1.Ex7.solved |
X1, 1.2.1-7 | |
| 1.2.1-8 | 25 | ▶ | K1 | TAOCP.S1_2_1.Ex8.a.solved, TAOCP.S1_2_1.Ex8.b.solved |
X1, 1.2.1-8 |
| 1.2.1-9 | 20 | K1 | TAOCP.S1_2_1.Ex9.solved |
X1, 1.2.1-9 | |
| 1.2.1-10 | 22 | M | K1 | TAOCP.S1_2_1.Ex10.solved |
X1, 1.2.1-10 |
| 1.2.1-11 | 30 | M | K3 | TAOCP.S1_2_1.Ex11.solved |
X1, 1.2.1-11 |
| 1.2.1-12 | 25 | M | K5 | TAOCP.S1_2_1.Ex12.solved |
X1, 1.2.1-12 |
| 1.2.1-13 | 23 | ▶ M | K1 | TAOCP.S1_2_1.Ex13.solved |
X1, 1.2.1-13 |
| 1.2.1-14 | 50 | K9 | not yet stated | X1, 1.2.1-14 | |
| 1.2.1-15 | 28 | ▶ HM | K1 | TAOCP.S1_2_1.Ex15.a.statement, TAOCP.S1_2_1.Ex15.b.statement, TAOCP.S1_2_1.Ex15.c.statement, TAOCP.S1_2_1.Ex15.d.statement, TAOCP.S1_2_1.Ex15.e.statement, TAOCP.S1_2_1.Ex15.f.statement, TAOCP.S1_2_1.Ex15.g.statement |
X1, 1.2.1-15 |
The order to do them: 1.2.1-1, 2 and 3 first. They are about the form of a proof by induction, and 2 and 3 ask where a wrong proof fails. Then 1.2.1-9 and 10, which are short inductions on inequalities, and 1.2.1-4, the lower bound that goes with eq. 1.2.1(3). Exercise 1.2.1-6 is the step of the proof of eq. 1.2.1(6) in this chapter, in the notation of the book. Exercises 1.2.1-12 and 13 go with the example of a run that does not stop: 12 is the case of numbers , and 13 adds a clock to the assertions so that they also prove the stop. Exercise 1.2.1-15 studies well-ordered sets in general and extends the last theorem of this chapter. Exercise 1.2.1-14 has the rating 50 and is a research project.
Lean
The Lean code of tamnd/taocp-lean at main (commit b48ef97) has the file TAOCP/V1/S1_2_1.lean. It has the extended Algorithm 1.2.1E as TAOCP.S1_2_1.algorithmE, with the example run of the book as a checked example, and the two equations of eq. 1.2.1(6) as the predicate TAOCP.S1_2_1.Eq6. That predicate only states the two equations. The file has no theorem that they hold at each pass, so the Node line of eq. 1.2.1(6) says "partial". The other Node lines of this chapter say "not yet stated". The exercises 1.2.1-1 to 13 have solutions in TAOCP/Solutions/S1_2_1/, and the exercise 1.2.1-15 has statements in TAOCP/Problems/S1_2_1/. The Mathlib names that the other statements will use are these. Each name was checked with #check against a local build of Mathlib.
- The principle of induction:
Nat.rec(the simple form, from ) andNat.strong_induction_on(the strong form). Both are in the list of spec 05.1 for Section 1.2.1, andTAOCP/Base/Check.leanchecks them. - The well-ordering:
Nat.find,Nat.find_specandNat.find_min', andWellFoundedfor a general well-founded relation.TAOCP.CompMethod.stepsof Section 1.1 isNat.findof the stop. - The Fibonacci numbers:
Nat.fib, withNat.fib_add_twofor the rule , andTAOCP.fibIntof the project for negative indices. The golden ratio isReal.goldenRatio, and eq. 1.2.1(5) isReal.goldenRatio_sq. - The extended Euclid algorithm: Mathlib's
Nat.xgcd,Nat.gcdAandNat.gcdB, withNat.gcd_eq_gcd_abfor the equation in the integers. These are a reference for the project's Algorithm 1.2.1E, not the algorithm itself. Mathlib does not say that its coefficients are the ones that Algorithm 1.2.1E returns, and a Lean statement that they agree is not yet stated.
The project states Algorithm 1.2.1E as a TAOCP.CompMethod in step format, which is TAOCP.S1_2_1.algorithmE, as TAOCP.S1_1.E.method is for Algorithm 1.1E. Eq. 1.2.1(6) will be an invariant of its step function. The method of assertions is then a theorem about TAOCP.CompMethod.run: if a property holds at the input and the step function keeps it, it holds at each state of the run. Its proof is the proof of Theorem C1.1.2.1.10 above.
Notes and history
Proofs that are induction in all but name are in the work of Francesco Maurolico (1575), and Blaise Pascal used the method in his treatise on the arithmetic triangle (written in 1654). Pierre de Fermat's method of infinite descent is the well-ordering form: a positive integer solution would give a smaller one, and there is no least one. The name "mathematical induction" is due to A. De Morgan (1838). R. Dedekind (1888) and G. Peano (1889) made induction one of the axioms of the integers.
The method of assertions has a long history. H. H. Goldstine and J. von Neumann (1947) put assertion boxes in their flow diagrams, and A. M. Turing (1949) gave a short proof of a program in the same spirit. P. Naur (1966) and R. W. Floyd (1967) made it a general method, and C. A. R. Hoare (1969) turned Floyd's method into a logic of programs, the base of the logics of program correctness that P7 teaches. Floyd's paper also gave the method of proof of termination by a quantity in a well-ordered set.
The partitions are the subject of a famous theory. G. H. Hardy and S. Ramanujan (1918) found the growth of , and H. Rademacher (1937) found an exact series. The extended form of Euclid's algorithm is old: the kuttaka of the Indian mathematician Aryabhata (about 499) solves the equation by a process of the same kind.
The project has no errata of Section 1.2.1 to report.
Section 1.2.1 of TAOCP is the first of the mathematical sections of Chapter 1. It teaches proof by induction, and then it uses induction to prove that an algorithm is correct: first the extended form of Euclid's algorithm, then any algorithm, by the method of assertions on a flow chart. This chapter of C1 explains each item of the section, gives each proof in full, and shows why a proof of correctness and a proof of termination are two different things.
The source of this page. Something is wrong? Report it.