Course: CS60030 Formal Systems

Slides:



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

Advanced programming tools at Microsoft
Completeness and Expressiveness
Auto-Generation of Test Cases for Infinite States Reactive Systems Based on Symbolic Execution and Formula Rewriting Donghuo Chen School of Computer Science.
Introduction to Formal Methods for SW and HW Development 09: SAT Based Abstraction/Refinement in Model-Checking Roberto Sebastiani Based on work and slides.
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
ECE Synthesis & Verification - L271 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Model Checking basics.
Temporal Logic and the NuSMV Model Checker CS 680 Formal Methods Jeremy Johnson.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Chair of Software Engineering Software Verification Stephan van Staden Lecture 10: Model Checking.
Thomas Ball, Rupak Majumdar, Todd Millstein, Sriram K. Rajamani Presented by Yifan Li November 22nd In PLDI 01: Programming Language.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Verification of parameterised systems
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
Software Verification via Refinement Checking Sagar Chaki, Edmund Clarke, Alex Groce, CMU Somesh Jha, Wisconsin.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
Introduction to Computability Theory
1 Model Checking, Abstraction- Refinement, and Their Implementation Based on slides by: Orna Grumberg Presented by: Yael Meller June 2008.
Abstractions. Outline Informal intuition Why do we need abstraction? What is an abstraction and what is not an abstraction A framework for abstractions.
Lecture 4&5: Model Checking: A quick introduction Professor Aditya Ghose Director, Decision Systems Lab School of IT and Computer Science University of.
CS 267: Automated Verification Lectures 14: Predicate Abstraction, Counter- Example Guided Abstraction Refinement, Abstract Interpretation Instructor:
Temporal Logic and Model Checking. Reactive Systems We often classify systems into two types: Transformational: functions from inputs available at the.
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball and Sriram K. Rajamani Software Productivity Tools, Microsoft Research Presented.
Predicate Abstraction for Software and Hardware Verification Himanshu Jain Model checking seminar April 22, 2005.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
Abstract Verification is traditionally done by determining the truth of a temporal formula (the specification) with respect to a timed transition system.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
50.530: Software Engineering
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
Benjamin Gamble. What is Time?  Can mean many different things to a computer Dynamic Equation Variable System State 2.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 3: Modular Verification with Magic, Predicate Abstraction.
Rule Checking SLAM Checking Temporal Properties of Software with Boolean Programs Thomas Ball, Sriram K. Rajamani Microsoft Research Presented by Okan.
Newton: A tool for generating abstract explanations of infeasibility1 The Problem P (C Program) BP (Boolean Program of P) CFG(P) CFG(BP)
Use of Models in Analysis and Design Sriram K. Rajamani Rigorous Software Engineering Microsoft Research, India.
1 Bisimulations as a Technique for State Space Reductions.
Automatically Validating Temporal Safety Properties of Interfaces Thomas Ball, Sriram K. MSR Presented by Xin Li.
1 Predicate Abstraction and Refinement for Verifying Hardware Designs Himanshu Jain Joint work with Daniel Kroening, Natasha Sharygina, Edmund M. Clarke.
Localization and Register Sharing for Predicate Abstraction Himanshu Jain Franjo Ivančić Aarti Gupta Malay Ganai.
The Yogi Project Software property checking via static analysis and testing Aditya V. Nori, Sriram K. Rajamani, Sai Deep Tetali, Aditya V. Thakur Microsoft.
SAT-Based Model Checking Without Unrolling Aaron R. Bradley.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 Automatically Validating Temporal Safety Properties of Interfaces - Overview of SLAM Parts of the slides are from
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Counter Example Guided Refinement CEGAR Mooly Sagiv.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
Verifying Regular Behavior of C modules Sagar Chaki, Edmund Clarke, Alex Groce, CMU Somesh Jha, Wisconsin.
Counterexample-Guided Abstraction Refinement By Edmund Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith Presented by Yunho Kim Provable Software.
Presentation Title 2/4/2018 Software Verification using Predicate Abstraction and Iterative Refinement: Part Bug Catching: Automated Program Verification.
Basic concepts of Model Checking
Formal methods: Lecture
Hardware Verification
Program Analysis via Satisfiability Modulo Path Programs
CIS 842: Specification and Verification of Reactive Systems
CSCI1600: Embedded and Real Time Software
Over-Approximating Boolean Programs with Unbounded Thread Creation
Formal Methods in software development
CSCI1600: Embedded and Real Time Software
Computer Security: Art and Science, 2nd Edition
CSCI1600: Embedded and Real Time Software
50.530: Software Engineering
Scalability in Model Checking
Abstraction, Verification & Refinement
The Zoo of Software Security Techniques
Predicate Abstraction
Formal Methods in software development
Presentation transcript:

Course: CS60030 Formal Systems Program Verification Course: CS60030 Formal Systems Pallab Dasgupta Professor, Dept. of Computer Sc & Engg

Software Verification Is a software program free from bugs? What kind of bugs? Lint checking – Divide by zero, Variable values going out of range User specified bugs – Assertions Challenges: Real valued variables Huge state space if we have to consider all values Size of the program is much smaller than the number of paths to be explored Branchings, Loops We need to extract an abstract state machine from a program

Abstraction: Sound versus Complete Sound Abstraction If the abstraction shows no bugs, then the original program also doesn’t have bugs Complete Abstraction If the abstraction shows a bug, then the original program has a bug Due to undecidability of static analysis problems, we cant have a general procedure that is both sound and complete.

Techniques Abstract Static Analysis Abstract interpretation Numerical abstract domains Software Model Checking Explicit and symbolic model checking Predicate abstraction and abstraction refinement

Example Sample program: int i=0 do { assert( i <= 10); i = i+2; Control Flow Graph (CFG): Sample program: int i=0 do { assert( i <= 10); i = i+2; } while (i < 5); L1 i=0; L2 Error [i>10] [i10] [i<5] L3 i=i+2; L4 [i5] L5

Concrete Interpretation Sample program: int i=0 do { assert( i <= 10); i = i+2; } while (i < 5); Philosophy: Collect the set of possible values of i until a fixed point is reached L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] Int {0} {2}  Iteration-1 L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] Int {0,2} {2,4}  Iteration-2 L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] Int {0,2,4} {2,4,6} {6} Iteration-3

Abstract Interpretation Sample program: int i=0 do { assert( i <= 10); i = i+2; } while (i < 5); Abstract Interpretation Philosophy: Use an abstract domain instead of value sets Example: We may use value intervals instead of value sets L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] [min, max] [0,0] [2,2] [ ] Iteration-1 L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] [min, max] [0,2] [2,4] [ ] Iteration-2 L1 L2 L3 L4 L5 Error i=0; [i>10] [i10] i=i+2; [i<5] [i5] [min, max] [0,4] [2,6] [5,6] Iteration-3 Actually, the value 5 is not possible here

Numerical Abstract Domains The class of invariants that can be computed, and hence the properties that can be proved, varies with the expressive power of a domain An abstract domain can be more precise than another The information loss between different domains may be incomparable Examples: The domain of Signs has three values: {Pos, Neg, Zero} Intervals are more expressive than signs. Signs can be modeled as [min,0], [0,0], and [0,max] The domain of Parities abstracts values as Even and Odd Signs or Intervals cannot be compared with Parities.

Model Checking with Predicate Abstraction A heavy-weight formal analysis technique Recent successes in software verification, e.g., SLAM at Microsoft The abstraction reduces the size of the model by removing irrelevant details The abstract model is then small enough for an analysis with a BDD-based Model Checker Idea: only track predicates on data, and remove data variables from model Mostly works with control-flow dominated properties Source of these slides: D. Kroening: SSFT12 – Predicate Abstraction: A Tutorial

Outline Introduction Existential Abstraction Predicate Abstraction for Software Counterexample Guided Abstraction Refinement Computing Existential Abstractions of Programs Checking the Abstract Model Simulating the Counterexample Refining the Abstraction

Predicate Abstraction as Abstract Domain We are given a set of predicates over S, denoted by Π1, . . . , Πn. An abstract state is a valuation of the predicates: Sˆ = Bn The abstraction function: α(s) = (Π1(s), . . . , Πn(s))

Predicate Abstraction: the Basic Idea Concrete states over variables x, y: x = 1 y = 0 y = 1 y = 2 x = 2 x = 0 Predicates: p1 ⇐⇒ x > y p2 ⇐⇒ y = 0

Predicate Abstraction: The Basic Idea Concrete states over variables x, y: x = 2 y = 0 p1, p2 x = 2 x = 0 y = 1 y = 0 p1, ¬ p2 ¬ p1, p2 x = 1 y = 0 x=1 y=1 x = 1 y = 2 ¬ p1, ¬ p2 Predicates: p1 p2 ⇐⇒ x > y ⇐⇒ y = 0 Abstract Transitions? 6

Existential Abstraction1 Definition (Existential Abstraction) A model Mˆ = (Sˆ, Sˆ0, Tˆ) is an existential abstraction of M = (S, S0, T ) with respect to α : S → Sˆ iff ∃ s ∈ S0. α(s) = sˆ ⇒ sˆ ∈ Sˆ0 and ∃ (s, st) ∈ T. α(s) = sˆ ∧ α(st) = sˆt ⇒ (sˆ, sˆt) ∈ Tˆ. 1Clarke, Grumberg, Long: Model Checking and Abstraction, ACM TOPLAS, 1994

Minimal Existential Abstractions There are obviously many choices for an existential abstraction for a given α. Definition (Minimal Existential Abstraction) A model Mˆ = (Sˆ, Sˆ0, Tˆ) is the minimal existential abstraction of M = (S, S0, T ) with respect to α : S → Sˆ iff ∃ s ∈ S0. α(s) = sˆ ⇔ sˆ ∈ Sˆ0 and ∃ (s, st) ∈ T. α(s) = sˆ ∧ α(st) = sˆt ⇔ (sˆ, sˆt) ∈ Tˆ. This is the most precise existential abstraction.

Existential Abstraction We write α(π) for the abstraction of a path π = s0, s1, . . .: α(π) = α(s0), α(s1), . . . 9

Existential Abstraction We write α(π) for the abstraction of a path π = s0, s1, . . .: α(π) = α(s0), α(s1), . . . Lemma Let Mˆ be an existential abstraction of M . The abstraction of every path (trace) π in M is a path (trace) in Mˆ . π ∈ M ⇒ α(π) ∈ Mˆ Proof by induction. We say that Mˆ overapproximates M . 9

Abstracting Properties Reminder: we are using a set of atomic propositions (predicates) A, and a state-labelling function L : S → P(A) in order to define the meaning of propositions in our properties. 10

Abstracting Properties We define an abstract version of it as follows: First of all, the negations are pushed into the atomic propositions. E.g., we will have x = 0 ∈ A and x ≠ 0 ∈ A

Abstracting Properties An abstract state sˆ is labelled with a ∈ A iff all of the corresponding concrete states are labelled with a. a ∈ Lˆ(sˆ) ⇔ ∀ s | α(s) = sˆ. a ∈ L(s) This also means that an abstract state may have neither the label x = 0 nor the label x ≠ 0 – this may happen if it concretizes to concrete states with different labels!

Conservative Abstraction The keystone is that existential abstraction is conservative for certain properties: Theorem (Clarke/Grumberg/Long 1994) Let φ be a ∀CTL* formula where all negations are pushed into the atomic propositions, and let Mˆ be an existential abstraction of M . If φ holds on Mˆ , then it also holds on M . Mˆ |= φ ⇒ M |= φ We say that an existential abstraction is conservative for ∀CTL* properties. The same result can be obtained for LTL properties. The proof uses the lemma and is by induction on the structure of φ. The converse usually does not hold.

p1, ¬p2 ¬p1, p2 p1, p2 ¬p1, ¬p2 Back to the Example x = 2 y = 0 x = 2 x = 0 y = 1 y = 0 p1, ¬p2 ¬p1, p2 x = 1 x = 1 y = 1 y = 2 x = 1 y = 0 ¬p1, ¬p2 15

p1, ¬p2 ¬p1, p2 p1, p2 ¬p1, ¬p2 Let’s try a Property x = 2 y = 0 x = 1 x = 2 x = 0 y = 1 y = 0 p1, ¬p2 ¬p1, p2 x = 1 x = 1 y = 1 y = 2 ¬p1, ¬p2 Property: x > y ∨ y ≠ 0 ⇐⇒ p1 ∨ ¬ p2

✔ ✔ ✔ p1, p2 p1, ¬p2 ¬p1, p2 ¬p1, ¬p2 Let’s try a Property x = 2 y = 1 ✔ ✔ x = 2 y = 1 p1, p2 x = 1 y = 0 x = 2 y = 0 x = 0 y = 0 p1, ¬p2 ¬p1, p2 ✔ x = 1 y = 1 x = 1 y = 2 ¬p1, ¬p2 Property: x > y ∨ y ≠ 0 ⇐⇒ p1 ∨ ¬ p2 16

p1, p2 p1, ¬p2 ¬p1, p2 ¬p1, ¬p2 Another Property x = 2 y = 0 x = 1 x > y ⇐⇒ p1

✔ ✔ p1, p2 p1, ¬p2 ¬p1, p2 ¬p1, ¬p2 Another Property x = 2 y = 0 x = 1 x > y ⇐⇒ p1

✔ ✔ ✘ p1, p2 p1, ¬p2 ¬p1, p2 ¬p1, ¬p2 Another Property x = 2 y = 0 ✔ ✔ x = 2 y = 0 p1, p2 x = 1 y = 0 x = 2 y = 0 x = 0 y = 0 p1, ¬p2 ¬p1, p2 ✘ x = 1 y = 1 x = 1 y = 2 ¬p1, ¬p2 Property: x > y ⇐⇒ p1 17

✔ ✔ ✘ p1, p2 p1, ¬p2 ¬p1, p2 ¬p1, ¬p2 Another Property x = 2 y = 0 ✔ ✔ x = 2 y = 0 p1, p2 x = 1 y = 0 x = 2 y = 0 x = 0 y = 0 p1, ¬p2 ¬p1, p2 ✘ x = 1 y = 1 x = 1 y = 2 ¬p1, ¬p2 Property: x > y ⇐⇒ p1 But: the counterexample is spurious 17

SLAM Microsoft blames most Windows crashes on third party device drivers The Windows device driver API is quite complicated Drivers are low level C code SLAM: Tool to automatically check device drivers for certain errors SLAM is shipped with Device Driver Development Kit Full detail available at http://research.microsoft.com/slam/

SLIC Finite state language for defining properties Monitors behavior of C code Temporal safety properties (security automata) familiar C syntax Suitable for expressing control-dominated properties e.g., proper sequence of events can track data values

SLIC Example acq unlocked locked rel s t a t e { enum { Locked , Unlocked } s = Unlocked ; } KeAcquireSpinLock . e n t r y { i f ( s==Locked ) abort ; e l s e s = Locked ; KeReleaseSpinLock . e n t r y { i f ( s==Unlocked ) abort ; e l s e s = Unlocked ; acq unlocked locked rel

SLIC Example acq unlocked locked rel rel acq error s t a t e { enum { Locked , Unlocked } s = Unlocked ; } KeAcquireSpinLock . e n t r y { i f ( s==Locked ) abort ; e l s e s = Locked ; KeReleaseSpinLock . e n t r y { i f ( s==Unlocked ) abort ; e l s e s = Unlocked ; acq unlocked locked rel rel acq error

Refinement Example do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); 21

Does this code obey the locking rule? Refinement Example do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); Does this code obey the locking rule? 21

Refinement Example do { KeAcquireSpinLock (); if (∗) { KeReleaseSpinLock (); } } while(∗); 22

Refinement Example U L E do { KeAcquireSpinLock (); if (∗) { KeReleaseSpinLock (); } } while(∗); 22

Refinement Example L U E do { KeAcquireSpinLock (); if (∗) { KeReleaseSpinLock (); } } while(∗); 22

Refinement Example L U E do { KeAcquireSpinLock (); if (∗) { KeReleaseSpinLock (); } } while(∗); Is this path concretizable? 22

Refinement Example L U E do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); 23

Refinement Example L U E do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); L E U This path is spurious! 23

Refinement Example L U E do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); L E U Let’s add the predicate nPacketsOld==nPackets 23

Refinement Example KeAcquireSpinLock (); nPacketsOld = nPackets; do { if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); L E U b=true; Let’s add the predicate nPacketsOld==nPackets 23

!b Refinement Example KeAcquireSpinLock (); nPacketsOld = nPackets; do { KeAcquireSpinLock (); nPacketsOld = nPackets; if (request) { request = request−>Next; KeReleaseSpinLock (); nPackets++; } } while(nPackets != nPacketsOld); KeReleaseSpinLock (); L E U b=true; b=b?false:∗; !b Let’s add the predicate nPacketsOld==nPackets 23

Refinement Example KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E 24

Refinement Example b KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E b 24

Refinement Example b b b b KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E b b b b 24

Refinement Example b !b KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E b !b 24

Refinement Example b !b KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E b !b 24

Refinement Example b !b KeAcquireSpinLock (); do { if (∗) { b=true; KeReleaseSpinLock (); } } while( ); b=true; b=b?false:∗; !b U L E b !b The property holds! 24