taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.1-6

Exercise 1.2.1-6

proved in Lean solution written

Rating20
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.1 of Volume 1. Companion chapter: Mathematical induction

The task

Show that the equations a′m+b′n=ca'm + b'n = c and am+bn=dam + bn = d stay true after step E4 of the extended Algorithm E, if they are true just before it.

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

Write the new values of a,a′,b,b′,c,da, a', b, b', c, d after E4 in terms of the old ones.

Hint 2

Use c=qd+rc = qd + r from step E2.

Solution

Show the solution

Before E4 assume a′m+b′n=ca'm + b'n = c, am+bn=dam + bn = d and c=qd+rc = qd + r (the last equation comes from E2, and E3 does not change it). Mark the new values by a star. Step E4 gives c∗=d,d∗=r,a′∗=a,a∗=a′−qa,b′∗=b,b∗=b′−qb.c^* = d,\quad d^* = r,\quad a'^* = a,\quad a^* = a' - qa,\quad b'^* = b,\quad b^* = b' - qb. Then a′∗m+b′∗n=am+bn=d=c∗,a'^* m + b'^* n = am + bn = d = c^*, which is the first equation after E4. For the second, a∗m+b∗n=(a′−qa)m+(b′−qb)n=(a′m+b′n)−q(am+bn)=c−qd=r=d∗.a^* m + b^* n = (a' - qa)m + (b' - qb)n = (a'm + b'n) - q(am + bn) = c - qd = r = d^*. So both equations hold after E4. □\square

Check

Take m=12m = 12, n=5n = 5. After E1: a′=1a' = 1, a=0a = 0, b′=0b' = 0, b=1b = 1, c=12c = 12, d=5d = 5. E2 gives q=2q = 2, r=2r = 2. E4 gives c=5c = 5, d=2d = 2, a′=0a' = 0, a=1−0=1a = 1 - 0 = 1, b′=1b' = 1, b=0−2⋅1=−2b = 0 - 2 \cdot 1 = -2. Then a′m+b′n=5=ca'm + b'n = 5 = c and am+bn=12−10=2=dam + bn = 12 - 10 = 2 = d. The python3 run of the whole algorithm for m,n≤79m, n \le 79 keeps both equations.

Remarks

This is the heart of the proof of Algorithm E. The equation for gcd⁡(c,d)\gcd(c, d) is kept by the argument of Section 1.1, and the condition d>0d > 0 of assertion A6 holds because r>0r > 0. The C1 chapter of Section 1.2.1 writes the same proof with its own names for the variables.

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.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.