310 likes | 318 Views
The Art of Effective Reasoning. Roland Backhouse Tallinn, Estonia, 19th November 2002. Quote of Oppenheimer. “The hallmark of a science is the avoidance of error” J. Robert Oppenheimer. Logic. . for all. . there exists. (anno 1966). Calculational Logic.
E N D
The Art of Effective Reasoning Roland Backhouse Tallinn, Estonia, 19th November 2002
Quote of Oppenheimer “The hallmark of a science is the avoidance of error” J. Robert Oppenheimer
Logic for all there exists (anno 1966)
Calculational Logic For all non-zero y and z y ×z is positive = (y is positive = z is positive)
Calculational Logic For all non-zero y and z y × z is positive = (y is positive = z is positive) (y ×z is positive = y is positive) = z is positive
Calculational Logic For all non-zero y and z y × z is positive = (y is positive = z is positive) (y ×z is positive = y is positive) = z is positive “The purpose of logic is not to mimic verbal reasoning but to provide a calculational alternative.” Edsger W. Dijkstra
Inequalities (Trichotomy) If a b then either a < b or b < a (Translation) If a < b then a+c < b+c If a < b and c > 0 then ac < bc
Inequalities (Trichotomy) If a b then either a < b or b < a ab a < b b < a (Translation) If a < b then a+c < b+c If a < b and c > 0 then ac < bc
Inequalities (Trichotomy) If a b then either a < b or b < a ab a < b b < a (Translation) If a < b then a+c < b+c a < b a+c < b+c If a < b and c > 0 then ac < bc
Inequalities (Trichotomy) If a b then either a < b or b < a ab a < b b < a (Translation) If a < b then a+c < b+c a < b a+c < b+c If a < b and c > 0 then ac < bc For all a,b,c, where ab and c0, a < b ac < bc 0 < c
Formal Proof 224 > 9 > 0 2 + 7 > 3 + 5
Goal-Directed Construction 2 + 7 ?3 + 5 = { property of squaring } (2 + 7)2? (3 + 5)2 = { property of squaring, and arithmetic } ? is “ > ”.
Complicating Proof 0 + 0 = 0 Rule (i) with a = 0 0(0+0) = 00 multiplying both sides by 0 00 + 00 = 00 “distributive rule”: a(b+c) = ab + ac (00 + 00) + x = 00 + x adding x to both sides, where x is the solution of 00 + x = 0 guaranteed by rule (ii) 00 + (00 + x) = 00 + x “associative rule”: a + (b+c) = (a+b) + c 00 + 0 = 0 using the property of x 00 = 0 using rule (i) with a = 00
Complicating Proof 0 + 0 = 0 0 + 0 = 0 Rule (i) with a = 0 0(0+0) = 00 multiplying both sides by 0 00 + 00 = 00 “distributive rule”: a(b+c) = ab + ac (00 + 00) + x = 00 + x adding x to both sides, where x is the solution of 00 + x = 0 guaranteed by rule (ii) 00 + (00 + x) = 00 + x “associative rule”: a + (b+c) = (a+b) + c 00 + 0 = 0 using the property of x 00 = 0 using rule (i) with a = 00 0 0 = 0
Goal-Directed Proof 00 = 0 = { a + 0 = a } 00 + 0 = 0 = { assume 00 + x = 0, Leibniz } 00 + (00 + x) = 00 + x = { associativity of + } (00 + 00) + x = 00 + x { Leibniz } 00 + 00 = 00 First four steps are the crucial ones ...
Goal-Directed Proof 00 + 00 = 00 = { distributivity } 0(0 + 0) = 00 { Leibniz } 0 + 0 = 0 = { a + 0 = a } true . … the rest is easy.
Inductive Construction 1° + 2° + + n° n 1¹ + 2¹ + + n¹ n(n+1)/2 1² + 2² + + n² n(n+1)(2n+1)/6 Conjecture: 1k + 2k + + nk is a polynomial inn of degree k+1.
Let S.n = 1 + 2 + + n P.n = (S.n = a + bn + cn² ) Then, n:: P.n = { induction } P.0 n:: P.n P.(n+1) = { P.0 = (S.0 = a) } 0 = a n:: P.n P.(n+1) = { substitution of equals for equals } 0 = a n:: P.n P.(n+1) [a:= 0]
P.(n+1) [a:= 0] = { definition } S.(n+1) = b(n+1) + c(n+1)² = { S.(n+1) = S.n + (n+1) } S.n + n + 1 = b(n+1) + c(n+1)² = { assume S.n = bn + cn² } bn + cn² + n + 1 = b(n+1) + c(n+1)² = 0 = (b + c - 1) + (2c - 1)n Hence n:: P.n a = 0 b = ½ c = ½
Towers of Hanoi An atomic move is a pair k,d where k is the disk number and d is the direction (clockwise or anticlockwise) the disk is to be moved. H.(n,d) is a sequence of atomic moves that results in moving the top n disks from one pole to the next pole in a direction d. H.(0,d) = [] H.(n+1,d) = H.(n,d) ; [n,d] ; H.(n,d)
Invariant The value of even.n d remains constant for every call of H. Proof: Compare H.(n+1,d) = H.(n,d) ; [n,d] ; H.(n,d) with even.(n+1) d = { contraposition: p q p q } (even.(n+1)) d = { property of even } even.n d .
Invariant The value of even.n d remains constant for every call of H. Hence: • The direction of movement of individual disks is constant. • Alternate disks move in alternate directions. • The direction of movementof disk 0 (the smallest disk) is given by even.0 d0 even.n dn where dk donates the direction of movement of disk k.
Invariant Equivalently, d0 dn even.n . That is, the smallest disk is moved in the same direction as the largest disk exactly when the number given to the largest disk is even.
Summary • Calculational Logic • Goal-directed • Construction, not Verification