Preface |
|
ix | |
Notes for Teachers |
|
xv | |
|
|
1 | (8) |
|
|
2 | (2) |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (3) |
|
Part 0 Learning the Ropes |
|
|
|
|
9 | (16) |
|
|
9 | (1) |
|
|
10 | (1) |
|
1.2 Working with the Verifier |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (4) |
|
|
17 | (2) |
|
1.6 Compiled versus Ghost |
|
|
19 | (2) |
|
|
21 | (4) |
|
|
25 | (38) |
|
|
26 | (2) |
|
|
28 | (1) |
|
|
29 | (3) |
|
2.3 Strongest Postconditions and Weakest Preconditions |
|
|
32 | (8) |
|
|
40 | (1) |
|
2.5 Conditional Control Flow |
|
|
41 | (4) |
|
2.6 Sequential Composition |
|
|
45 | (1) |
|
2.7 Method Calls and Postconditions |
|
|
46 | (4) |
|
|
50 | (3) |
|
2.9 Weakest Liberal Preconditions |
|
|
53 | (2) |
|
2.10 Method Calls with Preconditions |
|
|
55 | (2) |
|
|
57 | (1) |
|
|
58 | (2) |
|
|
60 | (1) |
|
|
60 | (3) |
|
3 Recursion and Termination |
|
|
63 | (20) |
|
|
64 | (2) |
|
3.1 Avoiding Infinite Recursion |
|
|
66 | (4) |
|
3.2 Well-Founded Relations |
|
|
70 | (2) |
|
|
72 | (7) |
|
3.4 Default decreases in Dafny |
|
|
79 | (1) |
|
|
80 | (3) |
|
|
83 | (12) |
|
|
84 | (1) |
|
4.1 Matching on Datatypes |
|
|
85 | (1) |
|
4.2 Discriminators and Destructors |
|
|
86 | (2) |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
89 | (1) |
|
4.6 Abstract Syntax Trees for Expressions |
|
|
90 | (3) |
|
|
93 | (2) |
|
|
95 | (42) |
|
|
96 | (1) |
|
|
96 | (3) |
|
|
99 | (3) |
|
|
102 | (4) |
|
|
106 | (4) |
|
|
110 | (5) |
|
5.6 Example: Commutativity of Multiplication |
|
|
115 | (3) |
|
5.7 Example: Mirroring a Tree |
|
|
118 | (4) |
|
5.8 Example: Working on Abstract Syntax Trees |
|
|
122 | (8) |
|
|
130 | (7) |
|
Part 1 Functional Programs |
|
|
|
|
137 | (24) |
|
|
137 | (1) |
|
|
138 | (1) |
|
6.2 Intrinsic versus Extrinsic Specifications |
|
|
139 | (3) |
|
|
142 | (2) |
|
|
144 | (2) |
|
|
146 | (1) |
|
|
147 | (4) |
|
6.7 Lemmas in Expressions |
|
|
151 | (6) |
|
6.8 Eliding Type Arguments |
|
|
157 | (1) |
|
|
158 | (3) |
|
|
161 | (14) |
|
|
162 | (1) |
|
|
162 | (3) |
|
7.2 Addition and Subtraction |
|
|
165 | (2) |
|
|
167 | (1) |
|
|
167 | (5) |
|
|
172 | (3) |
|
|
175 | (14) |
|
|
175 | (4) |
|
|
179 | (2) |
|
|
181 | (7) |
|
|
188 | (1) |
|
|
189 | (18) |
|
9.0 Grouping Declarations into Modules |
|
|
190 | (1) |
|
|
190 | (1) |
|
|
191 | (3) |
|
9.3 Modular Specification of a Queue |
|
|
194 | (7) |
|
9.4 Equality-Supporting Types |
|
|
201 | (3) |
|
|
204 | (3) |
|
10 Data-Structure Invariants |
|
|
207 | (28) |
|
10.0 Priority-Queue Specification |
|
|
208 | (2) |
|
10.1 Designing the Data Structure |
|
|
210 | (2) |
|
|
212 | (12) |
|
10.3 Making Intrinsic from Extrinsic |
|
|
224 | (5) |
|
|
229 | (6) |
|
Part 2 Imperative Programs |
|
|
|
|
235 | (22) |
|
|
235 | (6) |
|
11.1 Loop Implementations |
|
|
241 | (6) |
|
|
247 | (3) |
|
11.3 Summarizing the Loop Rule |
|
|
250 | (2) |
|
|
252 | (3) |
|
|
255 | (2) |
|
12 Recursive Specifications, Iterative Programs |
|
|
257 | (18) |
|
|
257 | (3) |
|
|
260 | (4) |
|
|
264 | (3) |
|
|
267 | (5) |
|
|
272 | (3) |
|
|
275 | (46) |
|
|
275 | (5) |
|
|
280 | (8) |
|
|
288 | (4) |
|
|
292 | (2) |
|
|
294 | (7) |
|
|
301 | (3) |
|
|
304 | (5) |
|
|
309 | (9) |
|
|
318 | (3) |
|
|
321 | (16) |
|
|
321 | (5) |
|
14.1 Basic Array Modification |
|
|
326 | (10) |
|
|
336 | (1) |
|
|
337 | (14) |
|
|
337 | (4) |
|
|
341 | (2) |
|
|
343 | (4) |
|
|
347 | (4) |
|
|
351 | (36) |
|
|
352 | (7) |
|
|
359 | (5) |
|
16.2 Simple Aggregate Objects |
|
|
364 | (10) |
|
16.3 Full Aggregate Objects |
|
|
374 | (8) |
|
|
382 | (5) |
|
17 Dynamic Heap Data Structures |
|
|
387 | (40) |
|
17.0 Lazily Initialized Arrays |
|
|
387 | (9) |
|
|
396 | (7) |
|
17.2 Binary Search Tree for a Map |
|
|
403 | (10) |
|
17.3 Iterator for the Map |
|
|
413 | (10) |
|
|
423 | (4) |
|
A Dafny Syntax Cheat Sheet |
|
|
427 | (6) |
|
|
433 | (12) |
|
B.0 Boolean Values and Negation |
|
|
433 | (1) |
|
|
433 | (1) |
|
B.2 Predicates and Well-Definedness |
|
|
434 | (1) |
|
B.3 Disjunction and Proof Format |
|
|
435 | (2) |
|
|
437 | (1) |
|
|
438 | (1) |
|
B.6 Free Variables and Substitution |
|
|
439 | (2) |
|
B.7 Universal Quantification |
|
|
441 | (1) |
|
B.8 Existential Quantification |
|
|
442 | (3) |
|
C Answers to Select Exercises |
|
|
445 | (14) |
References |
|
459 | (8) |
Index |
|
467 | |