This repository contains course materials for a Formal Methods course using Dafny for program verification.
The course is organized into 6 weeks, each with dedicated materials:
- Introduction to formal methods and Dafny
- Location:
week01_intro/
- Formal systems fundamentals, syntax, and semantics
- Location:
week02_formal_systems/
- Semantics of the IMP programming language
- Location:
week03_imp_semantics/
- Hoare logic and weakest precondition calculus
- Location:
week04_hoare_logic_wp/
- Weakest preconditions for loops and array operations
- Location:
week05_wp_loops_arrays/
- Strongest postcondition calculus and forward reasoning
- Location:
week06_sp_calculus/
Each week folder contains:
summary.md- Week overview and learning objectiveslab/- Lab exercises for hands-on practicedafny/- Dafny code examples and verification exercisesnotes/- Lecture notes and supplementary materials
Additional directories:
pdfs_source/- Original PDF source files for course materials
Two scripts are provided to verify all Dafny code in the repository:
./verify_all_labs.shpython3 verify_all_labs.pyBoth scripts will:
- Search for all
.dfyfiles inweek*/lab/andweek*/dafny/directories - Run
dafny verifyon each file - Display a summary of passed and failed verifications
- Dafny - Download and install the latest version
- Ensure
dafnyis available in your PATH
- Navigate to a specific week folder
- Review the
summary.mdfor an overview - Check
notes/for lecture materials - Complete exercises in
lab/ - Study examples in
dafny/ - Verify your code using the verification scripts
When adding new materials:
- Place PDFs in
pdfs_source/ - Add lab exercises to the appropriate week's
lab/directory - Add Dafny examples to the appropriate week's
dafny/directory - Update the week's
summary.mdas needed
This course material is provided for educational purposes.