. . . . . .
Program Construction and Reasoning
Shin-Cheng Mu
Institute of Information Science, Academia Sinica, Taiwan
2010 Formosan Summer School on Logic, Language, and Computation June 28 – July 9, 2010
1 / 97
Program Construction and Reasoning Shin-Cheng Mu Institute of - - PowerPoint PPT Presentation
Program Construction and Reasoning Shin-Cheng Mu Institute of Information Science, Academia Sinica, Taiwan 2010 Formosan Summer School on Logic, Language, and Computation June 28 July 9, 2010 . . . . . . 1 / 97 Introduction: On
. . . . . .
1 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited
2 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
3 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
4 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
4 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
4 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
4 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
◮ [−1, 3, 3, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 1, 2, −1]
5 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
◮ [−1, 3, 3, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 1, 2, −1]
5 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
◮ [−1, 3, 3, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 4, 2, −1]
◮ [−1, 3, 1, −4, −1, 1, 2, −1]
5 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
◮ What we want the program to do.
◮ How to do it.
6 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
7 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
◮ either by making it easy to check that whether a program is
◮ or by ensuring that programmers may only construct correct
7 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
8 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
9 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The Maximum Segment Sum Problem The Binary Search Challenge
10 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
11 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
12 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
12 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
◮ E.g. state space for the GCD program is (int × int).
◮ {X > 0 ∧ Y > 0} skip {X ≥ 0}. ◮ Note that the annotations need not be “exact.” 13 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
14 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
◮ E.g. (x ≤ 3)[x − 1/x] ⇔ x − 1 ≤ 3 ⇔ x ≤ 4. ◮
◮
15 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
16 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
16 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
17 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
18 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
18 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
19 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
19 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
19 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
20 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
21 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
21 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
21 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
22 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
23 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
23 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
23 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
24 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
24 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
25 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
25 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
25 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
25 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
25 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
26 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
26 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
27 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
27 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited Assignments Sequencing Selection Loop and loop invariants
28 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
29 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
30 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
31 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
32 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
33 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
34 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
35 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
◮ The invariant implies that −1 < m < N, thus a[−1] and a[N]
◮ No actual alteration necessary. ◮ It also enables us to handle possibly empty arrays
36 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
◮ but Bentley also employed a semi-formal reasoning using a
37 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
◮ l := m + 1 because a[m] is covered in another case; ◮ r := m − 1 because a range is represented differently.
◮ When K is not in a, the test is wasted. ◮ Rolfe claimed that single comparison is quicker in average. ◮ Knuth: single comparison needs 17.5 lg N + 17 instructions,
38 / 97
. . . . . .
Introduction: On Programs Correctness Program Verification using Hoare Logic Binary Search Revisited The van Gasteren-Feijen Approach Searching in a Sorted List Searching with Premature Return
39 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
40 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
41 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
42 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
43 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
44 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
I B J E A C L D K a c b
45 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
46 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
47 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
◮ Crane 0, Tortoise 5 . . . No. ◮ Crane 1, Tortoise 4 . . . No. ◮ Crane 2, Tortoise 3 . . . No. ◮ Crane 3, Tortoise 2 . . . Yes! ◮ Crane 4, Tortoise 1 . . . No. ◮ Crane 5, Tortoise 0 . . . No. 47 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
◮ If all 5 animals were cranes, there ought to be 5 × 2 = 10 legs. ◮ However, there are in fact 14 legs. The extra 4 legs must
◮ So there must be 5 − 2 = 3 cranes.
47 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
47 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
48 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
49 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
◮ x ⊕ y = y ⊕ x, ◮ x ⊕ (y ⊕ z) = (x ⊕ y) ⊕ z, and ◮ e ⊕ x = x = x ⊕ e,
◮ We will refer to this rule as to “split off n”. 50 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
51 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
◮ (+i : 3≤i<5 : i2) = 32 + 42 = 25. ◮ (+i, j : 3≤i≤j<5 : i × j) = 3 × 3 + 3 × 4 + 4 × 4. ◮ (∧i : 2≤i<9 : odd i ⇒ prime i) = true. ◮ (↑ i : 1≤i<7 : −i2 + 5i) = 6 (when i = 2 or 3).
52 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Quantifier manipulation
◮ (#i : false : F i) = 0, ◮ (#i : 0 ≤ i < n + 1 : F i) = (#i : 0 ≤ i < n : F i) + #(F n). 53 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
54 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
55 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
◮ {P} do ¬Q → S od {P ∧ Q}.
56 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
57 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
58 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
59 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
60 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
61 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
61 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
61 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
61 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
61 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
62 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
62 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
62 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
63 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
64 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
65 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
66 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
66 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
67 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
68 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
69 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
70 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
71 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
72 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
◮ Expect to see even longer expressions later!
◮ Like map, filter, foldr. . . in functional programming? ◮ More on this issue later. 73 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
74 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
74 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
74 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
74 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
75 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
76 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
◮ ‘computed’ ⊕ ‘to be computed’ = k X. ◮ Strategy: keep shifting stuffs from right hand side of ⊕ to the
77 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
78 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
79 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
80 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
81 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here? Taking Conjuncts as Invariants Replacing Constants by Variables Strengthening the Invariant Tail Invariants
82 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
83 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
84 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
84 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
85 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
85 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
86 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
87 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
88 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
89 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
◮ taking conjuncts as invariants; ◮ replacing constants by variables; ◮ strengthening the invariant; ◮ tail invariants.
90 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
91 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
92 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
93 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
94 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
◮ Extra care must be taken when we introduce subroutines, ◮ which is why procedure calls were such a big issue.
95 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
96 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
97 / 97
. . . . . .
What is a Proof, Anyway? Loop construction
Where to Go from Here?
◮ Plenty of tools around for program verification basing on
98 / 97