spin beginners tutorial
play

SPIN Beginners Tutorial Grenoble, France Thursday 11-Apr-2002 Theo - PDF document

Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 SPIN 2002 Workshop SPIN Beginners Tutorial Grenoble, France Thursday 11-Apr-2002 Theo C. Ruys University of Twente Formal Methods & Tools group


  1. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 SPIN 2002 Workshop SPIN Beginners’ Tutorial Grenoble, France Thursday 11-Apr-2002 Theo C. Ruys University of Twente Formal Methods & Tools group http://www.cs.utwente.nl/~ruys Credits should go to … • Gerard Holzmann (Bell Laboratories) Developer of SPIN, Basic SPIN Manual. • Radu Iosif (Kansas State University, USA) Course: Specification and Verification of Reactive Systems (2001) • Mads Dam (Royal Institute of Technology, Sweden) Course: Theory of Distributed Systems (2001). • Bengt Jonsson (Uppsala University, Sweden) Course: Reactive Systems (2001). • Joost-Pieter Katoen (University of Twente) Course: Protocol/System Validation (2000). Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 2 1 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  2. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 Audience & Contents • Basic SPIN intended audience: people totally new to (model checking and) SPIN • Advanced SPIN intended audience: people at least at the level of “Basic SPIN” • Contents Emphasis is on “using SPIN” not on technical details. In fact, we almost regard SPIN as a black box. We just want to “press-the-button”. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 3 Common Design Flaws • Deadlock In designing distributed systems: network applications, • Livelock, starvation data communication protocols, multithreaded code, • Underspecification client-server applications. – unexpected reception of messages • Overspecification Designing concurrent (software) – Dead code systems is so hard, that these • Violations of constraints flaws are mostly overlooked... – Buffer overruns – Array bounds violations • Assumptions about speed Fortunately, most of these design errors can be detected – Logical correctness vs. using model checking techniques! real-time performance Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 4 2 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  3. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 What is Model Checking? • [Clarke & Emerson 1981]: “Model checking is an automated technique that, given a finite-state model of a system and a logical property, systematically checks whether this property holds for (a given initial state in) that model.” � ���������������������������������� �������������� � � M | ������������� M ������������������������� ���������������� �������� � ���������������������������������� � ������������������������������� Although finite-state, the model of a system typically � ����� ��������� ����� ���������� grows exponentially. ����������������� ��������������� Based on [Vardi & Wolper 1986]. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 5 System Development System Engineering “Classic” Model Checking Analysis Design “Modern” Code Model Checking Testing Classic “waterfall model” [Pressman 1996] Maintenance Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 6 3 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  4. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 “Classic” Model Checking (initial) Design (manual) abstractions Model Abstract Checker Verification Model refinement techniques Implementation Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 7 “Modern” Model Checking Implementation systematic abstraction techniques Model Verification Model Checker • Abstraction is the key activity in both approaches. • This talk deals with pure SPIN, i.e., the “classic” model checking approach. To cope with the state space explosion. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 8 4 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  5. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 Verification vs. Debugging • Two (extreme) approaches with respect to the application of model checkers. – verification approach: tries to ascertain the correctness of a detailed model M of the system under validation. – debugging approach: tries to find errors in a model M . • Model checking is most effective in combination with the debugging approach. Automatic verification is not about proving correctness, but about finding bugs much earlier in the development of a system. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 9 Program suggestions • Some presentations at ETAPS/SPIN 2002 somehow related to this tutorial: – Dennis Dams Abstraction in Software Model Checking • Friday April 12 th 10.45-13.00 – John Hatcliff, Matthew Dwyer and Willem Visser Using the Bandera Tool Set and JPF (Tutorial 10) • Saturday April 13 th (full day) – SPIN Applications • Saturday April 13 th 11.00-12.30 “Modern” model checking approach. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 10 5 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  6. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 Basic SPIN • Gentle introduction to SPIN and Promela – SPIN Background – Promela processes – Promela statements – Promela communication primitives – Architecture of (X)Spin – Some demo’s: SPIN and Xspin • hello world Windows 2000: OK, but • mutual exclusion SPIN runs more smoothly • alternating bit protocol under Unix/Linux. – Cookie for the break Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 11 SPIN - Introduction (1) • SPIN (= Simple Promela Interpreter) = is a tool for analysing the logical conisistency of concurrent systems, specifically of data communication protocols. = state-of-the-art model checker, used by >2000 users – Concurrent systems are described in the modelling language called Promela. • Promela (= Protocol/Process Meta Language) – allows for the dynamic creation of concurrent processes. – communication via message channels can be defined to be • synchronous (i.e. rendezvous), or + features • asynchronous (i.e. buffered). from CSP – resembles the programming language C – specification language to model finite-state systems Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 12 6 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  7. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 SPIN - Introduction (2) • Major versions: 1.0 Jan 1991 initial version [Holzmann 1991] 2.0 Jan 1995 partial order reduction 3.0 Apr 1997 minimised automaton representation 4.0 late 2002 Ax: automata extraction from C code • Some success factors of SPIN (subjective!) : – “press on the button” verification (model checker) – very efficient implementation (using C) – nice graphical user interface (Xspin) – not just a research tool, but well supported – contains more than two decades research on advanced computer aided verification (many optimization algorithms) Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 13 Documentation on SPIN • SPIN’s starting page: http://netlib.bell-labs.com/netlib/spin/whatispin.html – Basic SPIN manual Also part of SPIN’s – Getting started with Xspin documentation distribution – Getting started with SPIN (file: html.tar.gz ) – Examples and Exercises – Concise Promela Reference (by Rob Gerth) – Proceedings of all SPIN Workshops • Gerard Holzmann’s website for papers on SPIN: http://cm.bell-labs.com/cm/cs/who/gerard/ • SPIN version 1.0 is described in [Holzmann 1991]. Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 14 7 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

  8. Theo C. Ruys - SPIN Beginners' Tutorial version: Friday, 13 September 2002 Promela Model • Promela model consist of: mtype = {MSG, ACK}; – type declarations chan toS = ... chan toR = ... – channel declarations bool flag; – variable declarations proctype Sender() { – process declarations ... – [ init process] process body } • A Promela model corresponds proctype Receiver() { with a (usually very large, but) ... } finite transition system, so – no unbounded data init { – no unbounded channels ... } – no unbounded processes creates processes – no unbounded process creation Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 15 Processes (1) • A process type ( proctype ) consist of – a name – a list of formal parameters – local variable declarations – body formal parameters name proctype Sender(chan in; chan out) { bit sndB, rcvB; local variables do :: out ! MSG, sndB -> in ? ACK, rcvB; if body :: sndB == rcvB -> sndB = 1-sndB :: else -> skip fi The body consist of a od sequence of statements. } Thursday 11-Apr-2002 Theo C. Ruys - SPIN Beginners' Tutorial 16 8 SPIN 2002 Workshop, Grenoble, 11-13 April 2002

Recommend


More recommend