Formal Verification of Systems Software
Notes for EECS 498
- Imperative, Declarative (like SQL).
int
is mathematical integer.- Immutatable is important (what about shadowing)
- Expression (evaluate a value) and Statement.
- Ghost (not compiled)
- Lemma syntax
- Pre and post conditions
- Prove by contradiction (?): a lemma proves false.
- The body of function is always visible.
Basics
Basic Quantifier
forall x | Q(x) :: P(x)
- statement form,
1 | forall x | Q(x) |
exists
needs a witness.
Imperative
1 | predicate IsMaxIndex(a:seq<int>, x:int) { |
Formal Specification
the most important part
Ways of specify:
- C-style assertions
- Postconditions
- Property / Invariants: “At most one node holds the lock at any time”
- Refinement: Linearizability. Equivalence to logically centralized service
Syntax
- Datatype member functions
- Calc statements: proves
a=b=c=d
using
1 | calc { |
Choose operator
var x :| x % 7 == 1;
(choosex
such that …)Modules
1 | module A { |
State Machine
Sample
1 | datatype Card = Shelf | Patron(name: string) |
Induction in Dafny
1 | ghost predicate Next(v: Variables, v': Variables) { |
Formal Verification of Systems Software