Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

AI-Powered Formal Verification

Teaching Software to Prove Itself: From Mathematical Foundations to AI-Driven Proof Engineering

AI-Powered Formal Verification
This book is 100% completeLast updated on 2026-11-26

What if you could prove your software works instead of simply hoping your tests catch every bug? From the mathematical foundations of formal verification to the practical power of Lean 4 and AI-driven proof engineering, this book shows how to make software prove its own correctness. A hands-on guide for engineers ready to move beyond testing and build software they can trust.

Minimum price

$25.00

$35.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
282
Pages
About

About

About the Book

Most software ships on the strength of a test suite, and most test suites check a few thousand cases out of a few trillion. This book is about the other way to get confidence in code: proving it correct. It opens with the familiar horror stories, a therapy machine that killed its patients and a rocket that lasted 37 seconds, then gets to work on the math. Logic, Hoare logic, temporal logic, SAT and SMT solvers, model checking, abstract interpretation, refinement types. From there it goes deep on proof assistants, Lean 4 in particular, down to the kernel, the elaborator and mathlib. The last part is the reason the book exists now rather than five years ago. Large language models have become surprisingly competent at writing proof scripts, and the book shows how to put them to work: generating tactics, repairing proofs that fail to compile and driving a pipeline from an English specification to a kernel-checked theorem. It is written for working engineers rather than logicians. Every idea arrives with a concrete example and the math is explained instead of assumed. By the end you will not be proving new theorems, but you will know how to take a piece of critical code and show, mechanically, that it does what it claims.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience spanning software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. His work focuses on understanding complex systems, uncovering security weaknesses and developing practical solutions that make technology more secure, reliable and effective.

Through Steve Publications, he collaborates with experienced researchers, engineers and industry experts to create practical, technically rigorous books on various topics not limited to self-improvement, software development, cybersecurity, cloud computing, DevOps, artificial intelligence and enterprise technologies. His mission is to make complex technical subjects accessible through clear explanations, real-world examples and hands-on exercises that help IT professionals, students and technology enthusiasts build valuable, practical skills.

Steve Publications embraces AI as a supporting tool for translation, proofreading and editorial refinement, not as a substitute for original research, technical expertise, or hands-on experience. Some contributors choose to publish under pseudonyms to protect their privacy or maintain professional boundaries.

Behind every book is a commitment to technical accuracy, practical relevance and continuous improvement. Our publications are written, reviewed and maintained by experienced professionals, with support from a private community of more than 420 engineers and researchers. Rather than prioritizing volume or mass-produced AI-generated content, we focus on delivering reliable, useful resources that readers can apply in real-world environments.

We also welcome experienced professionals who want to share their knowledge by writing or reviewing books, particularly in specialized and emerging technology fields. If you have expertise to contribute, we invite you to get in touch and explore opportunities to collaborate.

Our commitment is simple: To deliver books that respect our readers' time, support their professional growth and provide lasting practical value. If a book does not meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

Teaching Software to Prove Itself: From Mathematical Foundations to AI-Driven Proof Engineering

Part I: Foundations of Correctness

Chapter 1: Beyond Testing: Why Software Needs Proofs

  1. The Illusion of Exhaustive Testing
  2. Catastrophes, Bugs and the Cost of Trust
  3. What It Means for Software to Be Correct
  4. The Verification Landscape and This Book’s Roadmap

Chapter 2: The Language of Logic: Propositions, Predicates and Proofs

  1. Propositional Logic and Truth Tables
  2. Predicate Logic: Quantifiers and Variables
  3. Inference Rules and Proof Trees
  4. Proof Strategies: Contradiction, Induction, Cases
  5. From Propositions to Proofs: The Kernel Connection

Chapter 3: Sets, Functions, Relations and the Art of Induction

  1. Set Theory for Programmers
  2. Functions, Relations and Equivalences
  3. Induction and Recursion as the Same Idea
  4. Invariants: The Engine of Inductive Reasoning
  5. From Mathematics to Programs: The Big Picture

Chapter 4: Types, Terms and the Curry-Howard Correspondence

  1. Types as Specifications
  2. Simply Typed Lambda Calculus
  3. The Curry-Howard Correspondence
  4. From Simple Types to Dependent Types
  5. The Big Picture: Types, Logic and Computation

Part II: Semantics and Verification Calculi

Chapter 5: Giving Meaning to Programs: Operational and Denotational Semantics

  1. Why Semantics Matters
  2. Operational Semantics: Small Steps and Big Steps
  3. Denotational Semantics: Programs as Functions
  4. Axiomatic Semantics: Meaning Through Logic
  5. From Semantics to Verification

Chapter 6: Hoare Logic: Preconditions, Postconditions and Invariants

  1. Hoare Triples and the Logic of Commands
  2. Loop Invariants and Partial Correctness
  3. Total Correctness and Termination
  4. Weakest Preconditions: Inverting the Logic
  5. From Hoare Logic to Modern Verification

Chapter 7: Reasoning About Time: Temporal Logic and Reactive Systems

  1. Safety, Liveness and Fairness
  2. Linear Temporal Logic
  3. Computation Tree Logic and Branching Time
  4. Specifying Real Systems: APIs, Protocols and Schedulers
  5. From Temporal Logic to Model Checking

Chapter 8: From Propositions to Solvers: SAT, SMT and Z3

  1. SAT: The First Decision Problem
  2. SMT: SAT Modulo Theories
  3. Z3 and SMT-LIB: The Practitioner’s Solver
  4. From SAT/SMT to Verification

Part III: Automated Verification Techniques

Chapter 9: Model Checking: Exhaustive State-Space Reasoning

  1. The Model Checking Problem
  2. Explicit and Symbolic State Exploration
  3. LTL Model Checking and Counterexamples
  4. Tools in Practice: SPIN, NuSMV, TLA+, Apalache
  5. From Model Checking to Abstract Interpretation

Chapter 10: Abstract Interpretation: Sound Approximation at Scale

  1. Fixpoints and Iterative Analysis
  2. Abstract Domains and Transfer Functions
  3. Widening, Narrowing and Precision
  4. Real Analyses: Astrée, Polyspace and Bug Finders
  5. From Abstract Interpretation to Refinement Types

Chapter 11: Refinement Types and Liquid Types

  1. Types That Describe More Than Shape
  2. Refinement Types and Predicates
  3. Liquid Types and Type Inference
  4. Refinement in Practice
  5. From Refinement Types to Program Synthesis

Chapter 12: Program Synthesis: From Specification to Implementation

  1. The Synthesis Problem
  2. Enumeration, Sketching and CEGIS
  3. Learning-Guided and Grammar-Based Synthesis
  4. Synthesis Meets Verification

Part IV: The Proof Assistant Ecosystem

Chapter 13: Proof Assistants Compared: Architectures of Trust

  1. The Proof Kernel: Small, Trusted and Fast
  2. Proof Assistants at a Glance: Coq, Isabelle/HOL, Dafny, F*, Lean
  3. Proof Relevance, Extraction and Code Generation
  4. Choosing a Tool: A Decision Framework
  5. From Comparison to Deep Dive

Chapter 14: Lean 4 Inside and Out: Types, Kernel and Elaborator

  1. The Calculus of Inductive Constructions and Lean’s Type System
  2. The Lean 4 Kernel: Soundness and Trust
  3. The Elaborator and Implicit Arguments
  4. Universes, Metatheory and Extraction
  5. Bringing It All Together
  6. Looking Ahead

Chapter 15: Lean 4 Tactics, Metaprogramming and mathlib

  1. Term Mode vs Tactic Mode
  2. The Tactic Framework and Metaprogramming
  3. mathlib: The Library of Modern Mathematics
  4. Lean in the Engineering Workflow
  5. Bringing It All Together

Chapter 16: Verified Software in Lean: Algorithms, Data Structures and Mathematics

  1. Project Setup: lake, Directories and Dependencies
  2. Verified Lists and Sorting
  3. Verified Trees, Hashing and Search
  4. A Verified Micro-Math Library and Running the Suite
  5. What We Have Built

Chapter 17: Verification at Scale: Concurrency, Systems and Security

  1. Concurrency and the Heisenbugs of Shared State
  2. Distributed Systems and TLA+
  3. Security and Cryptographic Verification
  4. Financial Calculations and API Contracts
  5. Summary

Part V: AI Meets Verification

Chapter 18: The History and Landscape of Automated Theorem Proving

  1. Classical Automated Theorem Proving
  2. The Rise of SMT and Verification Engines
  3. Benchmarks: TPTP, Mizar, F2F, MiniF2F
  4. A Diagram of Automated Theorem Proving
  5. Summary

Chapter 19: Large Language Models as Proof Engineers

  1. LLMs for Mathematics: Capabilities and Limits
  2. LeanDojo, ReProver and Proof Editing
  3. AlphaProof, AlphaGeometry and Competition-Level Reasoning
  4. Hallucinations, Soundness and the Kernel as Arbiter
  5. A Diagram of LLM-Based Proof Engineering
  6. Summary

Chapter 20: Building an AI-Assisted Verification Pipeline

  1. Architecture: From Natural Language to Checked Proof
  2. Specification Generation and Refinement
  3. Agentic Proof Search with RAG and Feedback Loops
  4. The Complete Project: Repository, Commands and Results
  5. A Diagram of the Complete Pipeline
  6. Summary

Chapter 21: Trust, Soundness and the Future of Proof Engineering

  1. The Trust Stack: From Hardware to Theorems
  2. Specification Gaps and the Limits of Guarantees
  3. What AI Can and Cannot Replace
  4. The Road Ahead: Proof Engineering as a Discipline
  5. A Diagram of the Future Verification Ecosystem
  6. Conclusion of Part V

Conclusion: Software That Knows It Is Correct

References

  1. Mathematical Foundations
  2. Automated Reasoning and Solvers
  3. Proof Assistants
  4. Systems and Security Verification
  5. Automated Theorem Proving History
  6. AI and Theorem Proving
  7. Software Failures and Case Studies
  8. Verification Tools and Infrastructure

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub