A book about math, software, and using one to fix the other.
Written for the working programmer. No math background required.
227 pages. Ebook includes PDF and EPUB, DRM-free.
What’s this book?
This is a book about designing, verifying, and reasoning about software better. And it’s about how learning a little bit of logic, the mathematics of Booleans, unlocks all sorts of cool techniques in our field.
If you want to get a feel for what it’s like, try reading a sample chapter!
Is this mostly theoretical or does it have practical applications, too?
Everything in the book is meant to be practical. Early chapters are on topics like “simplifying conditionals” and “ensuring an API change won’t break clients”. Later chapters are on slightly more esoteric subjects, like “finding race conditions in hypothetical software designs” and “minimizing the wall clock time of a distributed task”. Not everything will be useful to everyone, but I hope everyone finds something useful!
Do I need to know math?
Nope! You don’t need to know math besides the Boolean AND, OR, and NOT that programmers pick up through daily experience. The book covers the rest of the math you need.
That said, you do need to know some programming! This book is meant for intermediate-to-advanced programmers and I assume the reader knows universal topics like loops, version control, testing, etc. Some chapters expect more specific knowledge like SQL or API design. Chapters are independent, though, so if something doesn’t fit your needs, go ahead and skip it.
What’s with the weird A and E in the title?
Logicians use the symbols ∀ and ∃ to mean “for all” and “there exists”, respectively. For example, we could write the sentence “everybody has a favorite color” as ∀p ∈ Person: ∃c ∈ Color: IsFavoriteColor(p, c).
To make learning the topics (and searching the book) easier, I use English words instead of math symbols. So the same expression would be all p in People: (some c in Color: IsFavoriteColor(p, c)).
How can I get it?
If you want to read the book on your phone or computer, you can get it as a PDF or EPUB. Here’s the PDF:
The print version is identical except with black-and-white printing and wider page margins. You can buy it on Amazon.
What’s in the book?
Here’s a table of contents and corresponding techniques:
- A Crash Course in Logic • predicates, booleans, sets, and quantifiers
- Refactoring Code • rewrite rules
- Writing Better Tests • property testing
- Composing Code Correctly • contracts, subtyping
- Proving Code Correct • formal verification, Dafny
- Working with Data • database theory
- Decoding Decisions • decision tables
- Modeling Domains • formal specification, Alloy
- Designing Systems • temporal logic, TLA+
- Solving Math Problems • constraint and SMT solving
- Logic Programming • Prolog and answer set programming
Plus some appendices on math notation, useful rewrite rules, and advanced topics in logic. All code samples are available on GitHub, along with a bunch of extra samples on the same topics that are not used in the book.
How long is the book?
It’s just about 50,000 words and a bit over 200 pages. The extra credits add another 4,000 words or so.
