Exercise · Volume 1 · 1.2.1-13
Exercise 1.2.1-13
proved in Lean solution written
| Rating | M23 |
|---|---|
| Markers | M (mathematical), recommended |
| Kind | K1, prove: show that a stated fact is true from the written solution |
| Section | Section 1.2.1 of Volume 1. Companion chapter: Mathematical induction |
The task
Add a clock to the extended Algorithm E and add to the assertions A1 to A6 conditions that imply and keep the inductive proof valid.
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
Count the steps of the first pass, then of each later pass. Each later pass runs E2, E3 and E4.
Hint 2
The quantity that decreases is . Try a bound of the form with a constant that depends on the arrow.
Hint 3
Choose so that each box keeps the bound: E2 and E3 add one each, E4 adds one and lowers by at least .
Solution
Show the solution
The clock rule is: each step E1, E2, E3 and E4 adds to at its beginning. Add these conditions, besides the old assertions:
- A1: .
- A2: .
- A3: .
- A4: and .
- A5: .
- A6: .
Check of each box. The old conditions are kept as in the proof of the text, and only the clock conditions need work.
- E1, from A1 to A2: goes from to .
- E2, from A2: and , so and A3 holds. From A6: grows by and does not change, so , which is A3.
- E3: grows by and does not change, so A3 gives . With this is A4, where because A3 has . With it is A5.
- E4, from A5: grows by , so with the old . The new value of is and with integers, so , that is . Then , which is A6.
The bound. In each assertion : this is clear in A3, A4 and A6, and in A5 since . At A2, . In A3, A4, A5 and A6 the bound with and gives . So every assertion implies . When the algorithm stops, A4 holds, so it stops after at most steps.
Check
Take , . E1 (), E2 (), E3 (): . E4 (): , . E2 (): , . E3 (): stop. The final , and A4 gives , with equality. The bound is reached for .
Remarks
The bound is weak for large : the number of passes is , as Section 4.5.3 shows. The clock is the usual way to turn a proof of assertions into a proof that the algorithm stops.
This solution is checked, and a person has not reviewed it yet. The source.
In Lean
proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.
- Problem:
TAOCP.S1_2_1.Ex13.statementaxioms: none - Solution:
TAOCP.S1_2_1.Ex13.solvedaxioms: Classical.choice, Quot.sound, propext
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.