Software analysis SET seminar.

Slides:



Advertisements
Similar presentations
1 Verification by Model Checking. 2 Part 1 : Motivation.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
Modular and Verified Automatic Program Repair Francesco Logozzo, Thomas Ball RiSE - Microsoft Research Redmond.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
Number Theory and Cryptography
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
Program analysis Mooly Sagiv html://
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Abstract Interpretation Part I Mooly Sagiv Textbook: Chapter 4.
From last time S1: l := new Cons p := l S2: t := new Cons *p := t p := t l p S1 l p tS2 l p S1 t S2 l t S1 p S2 l t S1 p S2 l t S1 p L2 l t S1 p S2 l t.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Overview of program analysis Mooly Sagiv html://
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
1 Program Analysis Systematic Domain Design Mooly Sagiv Tel Aviv University Textbook: Principles.
EE694v-Verification-Lect5-1- Lecture 5 - Verification Tools Automation improves the efficiency and reliability of the verification process Some tools,
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
Data Flow Analysis Compiler Design Nov. 8, 2005.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Overview of program analysis Mooly Sagiv html://
1 Tentative Schedule u Today: Theory of abstract interpretation u May 5 Procedures u May 15, Orna Grumberg u May 12 Yom Hatzamaut u May.
Design and Analysis of Algorithms
ECE355 Fall 2004Software Reliability1 ECE-355 Tutorial Jie Lian.
Reading and Writing Mathematical Proofs
Formal Methods Program Slicing & Dataflow Analysis February 2015.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 14: Numerical Abstractions Roman Manevich Ben-Gurion University.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Lecture 10 Abstract Interpretation using Fixpoints.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Λλ Fernando Magno Quintão Pereira P ROGRAMMING L ANGUAGES L ABORATORY Universidade Federal de Minas Gerais - Department of Computer Science P ROGRAM A.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 13: Abstract Interpretation V Roman Manevich Ben-Gurion University.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
Introduction to Hardware Verification ECE 598 SV Prof. Shobha Vasudevan.
Martin Hoffman Monica Hoffman. Goal To determine if a correlation exists between specified internal and dependability (external) metrics.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
Algorithms and Problem Solving
Software Metrics 1.
Definition CASE tools are software systems that are intended to provide automated support for routine activities in the software process such as editing.
Spring 2016 Program Analysis and Verification
Textbook: Principles of Program Analysis
Matching Logic An Alternative to Hoare/Floyd Logic
Input Space Partition Testing CS 4501 / 6501 Software Testing
CS 326 Programming Languages, Concepts and Implementation
Material in the textbook on pages
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
Symbolic Implementation of the Best Transformer
The Future of Software Engineering: Tools
Iterative Program Analysis Abstract Interpretation
Lecture Software Process Definition and Management Chapter 3: Descriptive Process Models Dr. Jürgen Münch Fall
Software Testing (Lecture 11-a)
Performance Optimization for Embedded Software
UNIT 3 CHAPTER 1 LESSON 4 Using Simple Commands.
Introduction To software engineering
SET seminar (2IS95).
Algorithms and Problem Solving
Basic Concepts of Algorithm
Loop-Level Parallelism
String Analysis for JavaScript Programs Using JSAI
Programming Languages, Preliminaries, History & Evolution
Pointer analysis John Rollinson & Kaiyuan Li
Presentation transcript:

Software analysis SET seminar

Software analysis is the process of (semi-)automatically establishing properties of the computer programs. a.k.a. Program analysis. Applications: For computers: Program correctness Execution optimization For humans: Quality assessment (maintainability, testability) / Faculteit Wiskunde en Informatica 29-11-2018

Axes of program analysis Compile-time (static) vs. run-time (dynamic) Dynamic: on-line vs. off-line Properties of interest: Structure vs. behavior Language-specific vs. language-independent Generic Language Technology (separate lecture) General-purpose languages vs. domain-specific ones / Faculteit Wiskunde en Informatica 29-11-2018

Static vs. dynamic Static Dynamic Applicable to incomplete or non-executable programs. Covers all possible executions. Usually less precise Dynamic Only executable programs. Covers only specific executions: On-line: current Off-line: those registered Usually more precise Can incur performance penalty Non-executable: special hardware that can be not available Some properties are better suited for static analysis, some for dynamic analysis / Faculteit Wiskunde en Informatica 29-11-2018

Static vs. Dynamic: Which way is easier? Sharing problem: say “yes” if p and q point to the same memory cell? Termination: say “yes” if the program terminates. / Faculteit Wiskunde en Informatica 29-11-2018

Structure vs. behavior Behavior: pointer sharing, termination Optimization, correctness Structure: How many execution paths pass through the procedure? How readable is the given code fragment? Maintainability, testability / Faculteit Wiskunde en Informatica 29-11-2018

Language-specific vs. language-independent Broader applicable Language-specific Can be fine tuned for a specific language / Faculteit Wiskunde en Informatica 29-11-2018

General purpose vs domain-specific Domain specific (usually) change often Changes in the domain Demand certain independence from a language? / Faculteit Wiskunde en Informatica 29-11-2018

Examples of analysis techniques / Faculteit Wiskunde en Informatica 29-11-2018

Numbers Software Metrics Static (usually) Structure Quality assessment: maintainability, testability, … Software Numbers / Faculteit Wiskunde en Informatica 29-11-2018

Metrics LOC % comments Cyclomatic complexity = #IF + #LOOP + 1 Source LOC, non-empty LOC, logical LOC % comments < 7% usually problematic Cyclomatic complexity = #IF + #LOOP + 1 Testability: #execution paths More than 15 – problematic Assignment A1 mentions the Halstead metrics… Logical = one commando on a number of lines / Faculteit Wiskunde en Informatica 29-11-2018

Dn – abstractness/stability balance Instable packages Depend upon many other classes No dependents Should be not extensible via inheritance (concrete) Stable packages Do not depend upon other classes Many dependents Should be extensible via inheritance (abstract) / SET / W&I

Instability: What does “depend” mean? 4 1 3 [Martin 2000] [Martin 1994] [JDepend] / SET / W&I

Dn – Distance from the main sequence Abstractness Dn = | Abstractness + Instability – 1 | 1 The closer Dn is to 0 – the better! Instability 1 / SET / W&I

Metrics: Research challenges Different definitions for the “same metrics” What is the impact on assessment of maintainability, testability, etc.? How can we prove that the metrics indeed reflect maintainability, testability, etc.? Statistical correlation with #bugs, maintenance effort? How can we aggregate the metrics? From methods to classes, packages and systems Average? Statistical distributions? / Faculteit Wiskunde en Informatica 29-11-2018

Behavioral analysis Software model checking Theorem proving Derive/construct a model of a software system Apply model checking techniques More: ask dr. Dragan Bosnacki. Theorem proving Add annotations Prove their correctness More: talk by dr. Michael Franssen Abstract interpretation: Today! / Faculteit Wiskunde en Informatica 29-11-2018

Abstract Interpretation: Example 2173  38 = 81574 or 2173  38 = 82574? Casting out nines: Sum the digits in the multiplicand n1, multiplier n2 and the product n to obtain s1, s2 and s. Divide s1, s2 and s by 9 to compute the remainder, that is, r1 = s1 mod 9, r2 = s2 mod 9 and r = s mod 9. If (r1  r2) mod 9  r then multiplication is incorrect The algorithm returns “incorrect” or “don’t know” Group A: apply casting out nines to the first multiplication (should fail), Group B: apply it to the second multiplication (should succeed)

Correctness argument Suppose r1 = n1 mod 9 and r2 = n2 mod 9 If n = n1  n2 then n mod 9 = (n1  n2) mod 9 hence n mod 9 = ((n1 mod 9)  (n2 mod 9)) mod 9 whence n mod 9 = (r1  r2) mod 9 = r therefore r = n mod 9 If r  n mod 9, then n  n1  n2

Abstract Interpretation: Basic idea Concrete domain Abstraction function α Abstract domain Computation is difficult or impossible Computation is easier Approximation Concrete domain Abstract domain Concretization function γ / Faculteit Wiskunde en Informatica 29-11-2018

Formalization Based on notions of a Galois connection Patrick Cousot & Radhia Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 238—252, Los Angeles, California, 1977. ACM Press, New York, NY, USA. / Faculteit Wiskunde en Informatica 29-11-2018

Lattices – a prelude Suppose S,  is a partially-ordered set :SSS is a join (the least upper bound) iff a  ab and b  ab for all a,bS if a  c and b  c, then ab  c for any cS :SSS is a meet (the greatest lower bound) ab  a and ab  b for all a,bS if c  a and c  b, then c  ab for any cS Partially ordered set. Who knows what a partial order is?

Complete lattices The join concept can often be lifted to sets iff t(T) for all TS and for all tT if ts for all tT then (T)s If meet can often be lifted analogously, then the lattice is complete A lattice that contains a finite number of elements is always complete

Abstract Interpretation: Revisited Concrete domain Abstract domain Computation is difficult or impossible Abstraction function α Concretization function γ Computation is easier Complete lattice / Faculteit Wiskunde en Informatica 29-11-2018

A, , C,  is Galois connection whenever A, A and C, C are complete lattices :CA and :AC are monotonic If c1 C c2 then (c1) A (c2) If a1 A a2 then (a1) C (a2) :AA and :CC satisfy c C ()(c) for all cC ()(a) A a for all aA α γ

A classic Galois connection example The concrete domain C,C,C,C is 2Z,,, The abstract domain A,A,A,A where: A = {,+,-,T}  A a AT for all aA join A and meet A are defined by: T - + 

The relationship between A and C The concretisation function :AC: () = Ø (+) = {nZ | n > 0} (-) = {nZ | n < 0} (T) = Z The abstraction function :CA is defined: (S) =  if S = Ø (S) = + else if n > 0 for all nS (S) = - else if n < 0 for all nS (S) = Z otherwise

Abstract Interpretation: Revisited Concrete domain Abstract domain * α γ Complete lattice ((a1) *C (a2)) C a1 *A a2 for all a1,a2A Approximation / Faculteit Wiskunde en Informatica 29-11-2018

Applications Verification: can a concurrent program deadlock? Is termination assured? Parallelization: are two or more tasks independent? What is the worst/base-case running time of function? Transformation: can a definition be unfolded? Will unfolding terminate? Implementation: can an operation be specialized with knowledge of its (global) calling context? / Faculteit Wiskunde en Informatica 29-11-2018

Abstract Interpretation: Challenges New abstract domains Intervals, octagons, more? New applications = new concrete domains New tools / Faculteit Wiskunde en Informatica 29-11-2018

Summary: Program analysis Compile-time (static) vs. run-time (dynamic) Dynamic: on-line vs. off-line Properties of interest: Structure vs. behavior Language-specific vs. language-independent Generic Language Technology (separate lecture) General-purpose languages vs. domain-specific ones Next time: Analysis in practice! / Faculteit Wiskunde en Informatica 29-11-2018