CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: Basics and Observables Copyright 2001-2004, Matt Dwyer, John Hatcliff,

Slides:



Advertisements
Similar presentations
Semantics Static semantics Dynamic semantics attribute grammars
Advertisements

Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Programming Languages and Paradigms
Data Abstraction II SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
LASER From Natural Language Requirements to Rigorous Property Specifications Lori A. Clarke Work done in collaboration with Rachel L. Smith, George S.
(c) 2007 Mauro Pezzè & Michal Young Ch 7, slide 1 Symbolic Execution and Proof of Properties.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
OASIS Reference Model for Service Oriented Architecture 1.0
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Chapter 2: Algorithm Discovery and Design
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
©Ian Sommerville 2000Software Engineering, 6/e, Chapter 91 Formal Specification l Techniques for the unambiguous specification of software.
From Module Breakdown to Interface Specifications Completing the architectural design of Map Schematizer.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
© Copyright Eliyahu Brutman Programming Techniques Course.
Describing Syntax and Semantics
Common Mechanisms in UML
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Understanding class definitions Looking inside classes.
Abstract Data Types and Encapsulation Concepts
Chapter 2: Algorithm Discovery and Design
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Precision Going back to constant prop, in what cases would we lose precision?
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
Abstract Types Defined as Classes of Variables Jeffrey Smith, Vincent Fumo, Richard Bruno.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 9 Slide 1 Formal Specification l Techniques for the unambiguous specification of software.
1 COSC 4406 Software Engineering COSC 4406 Software Engineering Haibin Zhu, Ph.D. Dept. of Computer Science and mathematics, Nipissing University, 100.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Invitation to Computer Science, Java Version, Second Edition.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: Sequencing Properties Copyright , Matt Dwyer, John Hatcliff,
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: LTL Model Checking Copyright , Matt Dwyer, John Hatcliff,
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Programming Languages and Paradigms Imperative Programming.
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Bogor-Simulation: Executing (Simulating) Concurrent Systems in Bogor Copyright.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
CIS 842: Specification and Verification of Reactive Systems Lecture 1: Course Overview Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The.
Design Model Lecture p6 T120B pavasario sem.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
CIS 842: Specification and Verification of Reactive Systems Lecture ADM: Course Administration Copyright , Matt Dwyer, John Hatcliff, Robby. The.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
Software Requirements Specification Document (SRS)
More about Java Classes Writing your own Java Classes More about constructors and creating objects.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Basic Concepts and Definitions
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Depth-Bounded: Depth-Bounded Depth-first Search Copyright 2004, Matt Dwyer, John.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
CIS 842: Specification and Verification of Reactive Systems
Specifications Liskov Chapter 9
Space-Reduction Strategies for Model Checking Dynamic Software
Informatics 121 Software Design I
Presentation transcript:

CIS 842: Specification and Verification of Reactive Systems Lecture Specifications: Basics and Observables Copyright , Matt Dwyer, John Hatcliff, and Robby. The syllabus and all lectures for this course are copyrighted materials and may not be used in other course settings outside of Kansas State University in their current form or modified form without the express written permission of one of the copyright holders. During this course, students are prohibited from selling notes to or being paid for taking notes by any person or commercial firm without the express written permission of one of the copyright holders.

CIS 842: Spec Basics and Observables 2 Objectives To understand the goals and basic elements of every formal specification formalism To understand the variety in ways that aspects of program behavior can be observed

CIS 842: Spec Basics and Observables 3 Outline What is a specification? Why write specifications? What are the building blocks of specs? What kinds of variation is there across specification languages? How can we define the execution behavior of a system that is relevant from the point of view of a specification? What do we want to observe?

CIS 842: Spec Basics and Observables 4 What is a Specification? A detailed, exact statement of particulars, especially a statement prescribing materials, dimensions, and quality of work for something to be built, installed, or manufactured. American Heritage Dictionary 2000 needs to be precise describes what is to be done

CIS 842: Spec Basics and Observables 5 What is a Formal Specification? A formal specification is the expression, in some formal language and at some level of abstraction, of a collection of properties that some system should satisfy Axel van Lamsweerde, Future of Software Engineering, 2000 formal language => precise properties … system should satisfy is a prescription!

CIS 842: Spec Basics and Observables 6 Why Write Specifications? To drive the implementation of a system Rare - usually driven from informal requirements Would require a complete specification - expensive To provide a redundant description of intent so we can check an implementation against something Generate tests Perform rigorous inspections Model check

CIS 842: Spec Basics and Observables 7 A Spec for Spec Languages Concise : if the spec is as large and complex as the system, you lose Understandable : spec needs to be right, so you better be able to read it General : want to be able to describe a wide range of system characteristics (here we stick to functionality) Think Different : forces you to express properties differently than solutions

CIS 842: Spec Basics and Observables 8 What’s a Good Spec? Consistent : no internal contradictions Unambiguous : has a clear meaning Complete : captures all of the essential aspects of the problem that are described elsewhere Minimal : doesn’t state irrelevant or implementation-specific properties

CIS 842: Spec Basics and Observables 9 Essential Parts of a Specification Components of the system that are related to the property (related to abstraction) x Constraints define what is demanded, desired, or restricted of the components x>0 Order describes how, if at all, the constrained- components related to one another if x>0 then after x++, x>0

CIS 842: Spec Basics and Observables 10 An Example Think about making a phone call What components of the phone are relevant? What characteristics of those components do we care about? How does the order in which components attain those characteristics influence the making of a phone call?

CIS 842: Spec Basics and Observables 11 Variations in Specification Style State-based : a condition or mode of being phone is off the hook call is connected Event-based : something that happens at a given place and time phone is lifted number 3 is dialed

CIS 842: Spec Basics and Observables 12 For You To Do Consider the property: Dial to connect to CIS Give a state-based specification Give an event-based specification Don’t forget to mention any implicit parts or constraints that are relevant

CIS 842: Spec Basics and Observables 13 States and Events Changes in state are caused by events x==5 x==6 Not all events cause a change in state x==5 x++ x=x+0

CIS 842: Spec Basics and Observables 14 Mixed States and Events When the door is open and the key is not in the ignition, the alarm beeps. door==open ignitionKey!=in beep Assigning x to 7 makes x greater than 0. x=7 x>0

CIS 842: Spec Basics and Observables 15 Variations in Specification Style Allowable behavior : define what a correctly functioning system is able to do offhook, number 7, connected Violations : define what a correctly functioning system can never do onhook, … anything but offhook …, connected

CIS 842: Spec Basics and Observables 16 Observing System Behavior A specification may observe the value of a component an operation applied to a component The language of value comparisons and operations is System description-language dependent, e.g., Java, BIRLite

CIS 842: Spec Basics and Observables 17 BIR-lite Observables Currently BIR-lite supports only 2 state observables Global variables any legal boolean-valued BIR expression may be used to define the constraints on a variable that are observed Existential thread program counter Property.existsThread(, ) there exists an instance of the named thread that is about to execute the guarded comment with the given label Need this (in part) because there is no explicit PC variable for a thread

CIS 842: Spec Basics and Observables 18 Example : BIR-lite system TwoDiningPhilosophers { extension Property for edu.ksu.cis.projects.bogor.ext.Property { expdef boolean existsThread(string, string); } boolean fork1; boolean fork2; thread Philosopher1() { loc loc0: live {} when !fork1 do { fork1 := true; } goto loc1; loc loc1: live {} when !fork2 do { fork2 := true; } goto loc2; loc loc2: live {} do { fork2 := false; } goto loc3; loc loc3: live {} do { fork1 := false; } goto loc0; } thread Philosopher2() {…} main thread Main() { loc loc0: do { assert(!(Property.existsThread("Philosopher1", "loc1") && !fork1))); } return; }

CIS 842: Spec Basics and Observables 19 Example : BIR-lite system TwoDiningPhilosophers { extension Property for edu.ksu.cis.projects.bogor.ext.Property { expdef boolean existsThread(string, string); } boolean fork1; boolean fork2; thread Philosopher1() { loc loc0: live {} when !fork1 do { fork1 := true; } goto loc1; loc loc1: live {} when !fork2 do { fork2 := true; } goto loc2; loc loc2: live {} do { fork2 := false; } goto loc3; loc loc3: live {} do { fork1 := false; } goto loc0; } thread Philosopher2() {…} main thread Main() { loc loc0: do { assert(!(Property.existsThread("Philosopher1", "loc1") && !fork1))); } return; }

CIS 842: Spec Basics and Observables 20 Specification Extensions Extensions are useful for implementing systems and for defining specifications extension Property for edu.ksu.cis.projects.bogor.ext.Property { expdef boolean existsThread(string, string); }

CIS 842: Spec Basics and Observables 21 Build Your Own Bogor allows one to define new observables ala extensions Property.allThread(, ) Property.noThread(, ) Property.samePlace( ) Not part of BIR-lite, but this gives you access to the entire state representation Can build powerful observables You’ll learn how to do this later

CIS 842: Spec Basics and Observables 22 BIR Functions BIR provides constructs for defining recursive functions over BIR variables fun p() returns boolean = Property.existsThread("Philosopher1", "loc1") && !fork1; This allows us to use named observables which aids readability assert(!p())

CIS 842: Spec Basics and Observables 23 Java Observables Value of a local variable Scalars References Value of object fields Explicit Implicit : locks Method call Qualified by parameter values

CIS 842: Spec Basics and Observables 24 Naming Instances existsThread(…) is used because threads are anonymous i.e., there is no variable that holds their value This is a general problem for heap allocated data 3 … an array … lenval

CIS 842: Spec Basics and Observables 25 Naming Instances It’s easy to talk about global references g.len>0  g.val!=null 3 … an array … lenval Global g

CIS 842: Spec Basics and Observables 26 Naming Instances How else can we talk about the instances of this class? All/some of the allocated instances All/some of the instances reachable from g All/some of the instances reachable by a reference chain of the form g.f.h … Need a way of defining these for easy use in specifications Use BIR extensions

CIS 842: Spec Basics and Observables 27 Naming Yields Independence Several of these notions of naming heap instances are quite abstract The set of instances of C that are reachable from g These make for good specifications since they are independent of implementation details g points to an array g points to the head of a linked list g points to the root of a tree

CIS 842: Spec Basics and Observables 28 Observing The Java Heap Shapes Tree, dag Values Ordered leaves of a tree Approximations Reach containment

CIS 842: Spec Basics and Observables 29 Assertions Assertions are a composite specification Implicit location constraint Explicit data constraint loc loc7: do { assert(x 3); } // && PC == loc7 goto loc14; }

CIS 842: Spec Basics and Observables 30 Invariants Are constraints that should hold in all system states explicit data constraint location constraints via thread location query extensions You’ve seen the assertion-in-a-thread trick Persistently evaluate the assertion thereby enforcing it in every state

CIS 842: Spec Basics and Observables 31 Invariants as Bogor Options It is possible to express invariant checks directly in Bogor If you have a boolean function expression that takes no parameters, e.g., fun p() returns boolean = Property.existsThread("Philosopher1", "loc1") && !fork1; Define an option …Isearcher.invariants=p

CIS 842: Spec Basics and Observables 32 Using Invariants An invariant is a very strong specification It says that the constraint is true in every system state e.g., the initial state, the final state, … Often times we only want a constraint to be enforced during some region of the system’s execution We can specify this using an implication as an invariant regionSpec  constraintSpec

CIS 842: Spec Basics and Observables 33 Examples Coherent variables e.g., head and tail pointers to a buffer e.g., length and array contents Invariants that describe relationships e.g., tail < head e.g., length = # of non-null elements Want to disable their enforcement when the values are being updated e.g., (!add && !take)  tail < head

CIS 842: Spec Basics and Observables 34 Summary Specifications are an essential element of rigorous system analysis Observables are boolean expressions that define constraints on component values that are relevant to a specification Specifications, like assertions and invariants, are built up from observables BIR-lite has primitive support for defining observables and writing specifications Bogor’s extension facility allows one to significantly enrich the spec language