Get introduced to software verification and proving correctness using the Microsoft Research-backed programming language, Dafny. While some other books on this topic are quite mathematically rigorous, this book will use as little mathematical symbols and rigor as possible, and explain every concept using plain English. It's the perfect primer for software programmers and developers with C# and other programming language skills.
Writing correct software can be hard, so you'll learn the concept of computation and software verification. Then, apply these concepts and techniques to confidently write bug-free code that is easy to understand. Source code will be available throughout the book and freely available via GitHub.
After reading and using this book you'll be able write correct, big free software source code applicable no matter which platform and programming language you use.
What You Will Learn
- Discover the Microsoft Research-backed Dafny programming language
- Explore Hoare logic, imperative and functional programs
- Work with pre- and post-conditions
- Use data types, pattern matching, and classes
- Dive into verification examples for potential re-use for your own projects
Who This Book Is For
Software developers and programmers with at least prior, basic programming experience. No specific language needed. It is also for those with very basic mathematical experience (function, variables).
About the Author |
|
ix | |
About the Technical Reviewer |
|
xi | |
Preface |
|
xiii | |
Languages and Systems |
|
xv | |
|
Chapter 1 Our First Program |
|
|
1 | (6) |
|
|
7 | (12) |
|
|
7 | (7) |
|
2.2 Predicate Logic and Quantifiers |
|
|
14 | (5) |
|
|
19 | (18) |
|
3.1 Variables and Assertions |
|
|
20 | (2) |
|
3.2 Methods and Functions |
|
|
22 | (3) |
|
3.3 Predicates (Triggers) and Lemmas |
|
|
25 | (1) |
|
|
26 | (4) |
|
3.5 Types and Pattern Matching |
|
|
30 | (7) |
|
Chapter 4 Mathematical Foundations |
|
|
37 | (10) |
|
|
37 | (6) |
|
|
43 | (4) |
|
|
47 | (14) |
|
5.1 Proofs by Truth Tables |
|
|
49 | (2) |
|
|
51 | (2) |
|
|
53 | (3) |
|
5.4 Sequent Calculus Notation |
|
|
56 | (2) |
|
5.5 Example: Proving a Mathematical Property |
|
|
58 | (3) |
|
|
61 | (16) |
|
|
61 | (4) |
|
|
65 | (2) |
|
6.3 Preconditions and Postconditions |
|
|
67 | (1) |
|
|
68 | (2) |
|
|
70 | (2) |
|
|
72 | (2) |
|
6.7 Example: Finding a Maximum Number in an Array |
|
|
74 | (3) |
|
Chapter 7 Mathematical Induction |
|
|
77 | (8) |
|
|
79 | (2) |
|
7.2 Manually Proving Induction in Dafny |
|
|
81 | (4) |
|
Chapter 8 Verification Exercises |
|
|
85 | (28) |
|
8.1 An Odd Implementation |
|
|
85 | (2) |
|
|
87 | (1) |
|
8.3 Mathematical Properties |
|
|
88 | (1) |
|
|
89 | (1) |
|
8.5 Miscellaneous Algorithms |
|
|
90 | (7) |
|
|
97 | (1) |
|
|
98 | (2) |
|
|
100 | (13) |
|
Chapter 9 Implementing a Formal System |
|
|
113 | (6) |
Appendix A Godel's Theorems |
|
119 | (4) |
Conclusion |
|
123 | (2) |
Bibliography |
|
125 | (2) |
Index |
|
127 | |
Boro Sitnikovski has over ten years of experience working professionally as a software engineer. He started programming with assembly on an Intel x86 at the age of ten. While in high school, he won several prizes in competitive programming, varying from 4th, 3rd, and 1st place. He is an informatics graduate - his bachelors thesis was titled Programming in Haskell using algebraic data structures, and his masters thesis was titled Formal verification of Instruction Sets in Virtual Machines. He has also published a few papers on software verification. Other research interests of his include programming languages, mathematics, logic, algorithms, and writing correct software. He is a strong believer in the open-source philosophy and contributes to various open-source projects. In his spare time, he enjoys some time off with his family.