Refinement, reusable libraries, instantiable classes K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Joint work with Kuat Yessenov, MIT IFIP WG 2.3 meeting Santa Barbara, CA 20 January 2011
Raise level of abstraction of programming languages Connect modeling and programming Simulate, test, model check, verify at all levels of the design
Higher-level data structures No loops Allow as much as possible … K. Rustan M. Leino
Bertrand’s programmer spectrum: Casual, Professional, Critical Refinement has had success for Critical Can refinement help Professional? What are good examples? How? Textual model for language? What IDE features? K. Rustan M. Leino
Critical embedded systems fixed variables and memory write code from scratch Professional applications programs dynamic variables and memory reuse libraries Is refinement up to this? K. Rustan M. Leino
class Cell { var data: int; } class Counter { var n: int; method Init() { n := 0; } method Inc() { n := n + 1; } method Get() returns (k: int) { k := n; } method M() returns (c: Cell) { } } K. Rustan M. Leino
method Main() { var cnt := new Counter; … call s := cnt.Get(); call t := cnt.Get(); assert s = t; } K. Rustan M. Leino
method Main() { var cnt := new Counter; … call s := cnt.Get(); call c := cnt.M(); c.data := c.data + 1; call t := cnt.Get(); assert s = t; } K. Rustan M. Leino
class CounterImpl refines Counter { var cell: Cell; coupling-invariant n = cell.data; … method Get() returns (k: int) { k := cell.data; } method M() returns (c: Cell) { c := cell;} K. Rustan M. Leino