Download presentation
Presentation is loading. Please wait.
Published byNancy Barber Modified over 9 years ago
1
K. Rustan M. Leino RiSE, Microsoft Research 1 Dec 2008 Invited talk, working group meeting COST Action IC0701, Formal Verification of Object-Oriented Software Madrid, Spain
2
experimental language sequential, object based (no subclassing) specifications in the style of dynamic frames coarse-grained frames (at the level of whole objects, not individual memory locations)
3
queue linked list with head/tail pointers in-situ list reversal integer set binary tree Schorr-Waite marking algorithm
4
Program ::= Class* Class ::= class C { Member* } Member ::= Field Method Function
5
var x : T;
6
T ::= bool int set seq C object
7
method M (Param*) returns (Param*) Spec* { Stmt* }
8
Stmt ::= var x: T; x := E; E.f := E’; x := new C ; call x* := E.M(E*); if (E) { Stmt* } else { Stmt* } while (E) invariant J; decreases F; { Stmt* } foreach (x in S) { x.f := E; }
9
Spec ::= requires E; modifies S; ensures E; where “modifies S” means modifies Heap ensures ( o,f Heap[o,f] = old(Heap)[o,f] o old(S) ¬ old(Heap)[o,alloc]) modifies clauses are enforced at every update
10
function F (Param*): T reads Rd; { Expr } produces definitional axiom: ( Heap,this,x F(Heap,this,x) = Expr)
11
ensures definitional axioms are consistent reading o.f requires o Rd calling a function G requires Rd G Rd produces frame axiom: ( h0,h1,this,x ( o,f o Rd h0[o,f] = h1[o,f]) F(h0,this,x) = F(h1,this,x))
12
*) well, pretty much… *
13
class C { var footprint: set ; function Valid(): bool reads {this},footprint; { this footprint … } …
14
method Init() modifies {this}; ensuresValid() fresh(footprint – {this});
15
method M() requires Valid(); modifies footprint; ensuresValid() fresh(footprint – old(footprint));
16
:Queue:Queue :Node:Node:Node:Node:Node:Node:Node:Node head tail
17
Specification (excerpt): ensures root.marked; ensures ( n, i n.marked 0 ≤ i < |n.children| n.children[i] = null n.children[i].marked); Loop invariant (excerpt): invariant t.marked; invariant ( n, i n.marked 0 ≤ i < |n.children| n nodeStack n.children[i] = null n.children[i].marked);
18
decreases { n | ¬ n.marked }, |nodeStack|, |t.children| – t.childrenVisited;
19
ensures root.marked; ensures ( n, i n.marked 0 ≤ i < |n.children| n.children[i] = null n.children[i].marked); ensures ( n Reach(root,n) ¬n.marked);
20
Dynamic-frame specifications are useful and flexible A language design around dynamic frames can be simple Thus good in teaching? Specifications are verbose, but perhaps simplification techniques can be applied (like in Spec# or Chalice) Currently missing in Dafny: scopes for axioms
21
Pure methods are hard, functions are easy SMT solvers work better with ghost fields than with functions Reachability is not always necessary in specifications Sets and sequences are nice as value types Generics are a cinch Decreases bound checks can be more liberal than naïve translation
22
SMT solvers can be used for functional- correctness verification Inductive predicates seem useful cases fit nicely with matching triggers take us in the direction of the input languages of interactive theorem provers Need: better views/visualizations of program states to clarify error messages and, generally, what’s going on
23
Try it for yourself: http://research.microsoft.com/boogie/dafny
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.