Parametric Shape Analysis via 3-Valued Logic

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Techniques for proving programs with pointers A. Tikhomirov.
Predicate Abstraction and Canonical Abstraction for Singly - linked Lists Roman Manevich Mooly Sagiv Tel Aviv University Eran Yahav G. Ramalingam IBM T.J.
Interprocedural Shape Analysis for Recursive Programs Noam Rinetzky Mooly Sagiv.
3-Valued Logic Analyzer (TVP) Tal Lev-Ami and Mooly Sagiv.
1 Cover Algorithms and Their Combination Sumit Gulwani, Madan Musuvathi Microsoft Research, Redmond.
Review of topics Final exam : -May 2nd to May 7 th - Projects due on May 7th.
Computability and Complexity 8-1 Computability and Complexity Andrei Bulatov Logic Reminder.
1 Lecture 07 – Shape Analysis Eran Yahav. Previously  LFP computation and join-over-all-paths  Inter-procedural analysis  call-string approach  functional.
1 Lecture 08(a) – Shape Analysis – continued Lecture 08(b) – Typestate Verification Lecture 08(c) – Predicate Abstraction Eran Yahav.
Discrete Abstractions of Hybrid Systems Rajeev Alur, Thomas A. Henzinger, Gerardo Lafferriere and George J. Pappas.
Specialized Reference Counting Garbage Collection using Data Structure Annotations By Eric Watkins and Dzin Avots for CS 343 Spring 2002.
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Finite Differencing of Logical Formulas for Static Analysis Thomas Reps University of Wisconsin Joint work with M. Sagiv and A. Loginov.
1 Verifying Temporal Heap Properties Specified via Evolution Logic Eran Yahav, Tom Reps, Mooly Sagiv and Reinhard Wilhelm
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Role Analysis Victor Kunkac, Patric Lam, Martin Rinard Laboratory for Computer Science, MIT Presentation by George Caragea CMSC631,
1 Shape Analysis via 3-Valued Logic Mooly Sagiv Tel Aviv University Shape analysis with applications Chapter 4.6
Invisible Invariants: Underapproximating to Overapproximate Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
A Semantics for Procedure Local Heaps and its Abstractions Noam Rinetzky Tel Aviv University Jörg Bauer Universität des Saarlandes Thomas Reps University.
Static Program Analysis via Three-Valued Logic Thomas Reps University of Wisconsin Joint work with M. Sagiv (Tel Aviv) and R. Wilhelm (U. Saarlandes)
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
Mark Marron IMDEA-Software (Madrid, Spain) 1.
Dagstuhl Seminar "Applied Deductive Verification" November Symbolically Computing Most-Precise Abstract Operations for Shape.
Program Analysis and Verification Noam Rinetzky Lecture 10: Shape Analysis 1 Slides credit: Roman Manevich, Mooly Sagiv, Eran Yahav.
1 Employing decision procedures for automatic analysis and verification of heap-manipulating programs Greta Yorsh under the supervision of Mooly Sagiv.
Shape Analysis Overview presented by Greta Yorsh.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Shape Analysis via 3-Valued Logic Mooly Sagiv Thomas Reps Reinhard Wilhelm
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
Symbolically Computing Most-Precise Abstract Operations for Shape Analysis Greta Yorsh Thomas Reps Mooly Sagiv Tel Aviv University University of Wisconsin.
Model construction and verification for dynamic programming languages Radu Iosif
Chapter 3 Part II Describing Syntax and Semantics.
1 Shape Analysis via 3-Valued Logic Mooly Sagiv Tel Aviv University Shape analysis with applications Chapter 4.6
ece 627 intelligent web: ontology and beyond
Semantics of Predicate Calculus For the propositional calculus, an interpretation was simply an assignment of truth values to the proposition letters of.
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
1 Program Analysis via 3-Valued Logic Mooly Sagiv, Tal Lev-Ami, Roman Manevich Tel Aviv University Thomas Reps, University of Wisconsin, Madison Reinhard.
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
Program Analysis via 3-Valued Logic Thomas Reps University of Wisconsin Joint work with Mooly Sagiv and Reinhard Wilhelm.
1 Numeric Abstract Domains Mooly Sagiv Tel Aviv University Adapted from Antoine Mine.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Shape & Alias Analyses Jaehwang Kim and Jaeho Shin Programming Research Laboratory Seoul National University
1 Simulating Reachability using First-Order Logic with Applications to Verification of Linked Data Structures Tal Lev-Ami 1, Neil Immerman 2, Tom Reps.
Interprocedural shape analysis for cutpoint-free programs Noam Rinetzky Tel Aviv University Joint work with Mooly Sagiv Tel Aviv University Eran Yahav.
Putting Static Analysis to Work for Verification A Case Study Tal Lev-Ami Thomas Reps Mooly Sagiv Reinhard Wilhelm.
Counterexample-Guided Abstraction Refinement By Edmund Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith Presented by Yunho Kim Provable Software.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Interprocedural shape analysis for cutpoint-free programs
Textbook: Principles of Program Analysis
Spring 2017 Program Analysis and Verification
ALGORITHMS part-1.
Beyond Strong vs. Weak Updates Isil Dillig, Thomas Dillig, Alex Aiken
Formal Modeling Concepts
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Program Analysis and Verification
(One-Path) Reachability Logic
Symbolic Implementation of the Best Transformer
Formal Program Specification
Parametric Shape Analysis via 3-Valued Logic
Formal Methods in software development
Formal Methods in software development
Chapter 4 Action Routines.
PROPOSITIONAL LOGIC - SYNTAX-
Symbolic Characterization of Heap Abstractions
Formal Methods in software development
A Semantics for Procedure Local Heaps and its Abstractions
Formal Program Specification
Presentation transcript:

Parametric Shape Analysis via 3-Valued Logic Mooly Sagiv Thomas Reps Reinhard Wilhelm

pointer analysis? points-to analysis? shape analysis? alias analysis?

The Shape-Analysis Problem For every program point, compute a finite characterization of the possible “shapes” of the heap-allocated data structures.

Formalizing “. . .” Informal: x y Formal: x y Summary Information

Why Shape Analysis? Capture storage invariants May-alias information x points to an acyclic list, cyclic list, tree, dag, etc. May-alias information Identify (absence of) sharing x and y point to structures that do not share cells “Dynamization” of static structure-description formalisms e.g., ADDS annotations [Hendren 94]

What’s New? Parametric framework for a class of shape-analysis algorithms “Rational reconstruction” of a number of previous shape-analysis methods [Jones & Muchnick 81] [Chase, Wegman, & Zadeck 90] [Stransky 93] [Assmann & Weinhardt 93] [Pleyvak, Chien, & Karamcheti 93] [Wang 94] [Sagiv, Reps, & Wilhelm 96, 98] New shape-analysis methods General abstraction principle  Much simpler proofs Basis for a tool that generates shape-analysis algorithms

Outline Using logic to describe stores Using logic to express store transformations Forming abstractions of stores Three-valued logic Using three-valued logic to express transformations of abstract stores

Using Logic to Describe Stores Predicate Symbols Whether variable x points to location u: x(u) Pointer fields: n(u1, u2) car(u1, u2) cdr(u1, u2) x u u1 u2 u1 u2 u1 u2

Using Logic to Describe Stores Formulas: Other Properties of Locations is(v)   v1,v2 : n(v1,v)  n(v2,v)  v1  v2 x y u3 u1 u2 is(u1) = 0 is(u2) = 1 is(u3) = 0 u3 u4 u1 u2 is(u1) = 0 is(u2) = 0 is(u4) = 0 is(u3) = 0

First-Order Logic (Syntax) Vocabulary Predicate symbols: p1, p2, . . ., pn Constant symbols: c1, c2, . . ., cm Function symbols: f1, f2, . . ., fk Formulas Variables Equality-predicate symbol: = Logical-constant symbols: 0, 1 Connectives: , ,  Quantifiers: , 

First-Order Logic (Semantics) Truth values: 0, 1 Logical structures Individuals: U = {u1, u2, . . ., un} Predicates: pi : U arity(pi)  {0, 1} In Our Application Logical structures = Concrete stores

An Example Individuals: U = {u1, u2, u3} Predicates: x u1 x u1 u3 u1 y u3 y u3 Individuals: U = {u1, u2, u3} Predicates:

Example (Cont’d) Individuals: U = {u1, u2, u3} Predicates: x u2 u3 u1 y u3 Individuals: U = {u1, u2, u3} Predicates:

First-Order Logic (Semantics) Assignments Z: free variables  individuals Meaning of a formula (Z)

Meaning of a Formula (v,v1,v2)  n(v1,v)  n(v2,v)  v1  v2 x u1 u2 y u3 (v,v1,v2)  n(v1,v)  n(v2,v)  v1  v2 Z = { v  u2, v1  u1, v2  u3 } (v,v1,v2)(Z) = ???

Meaning of a Formula (Z) pi(v1, …, vk) (Z) = pi (Z(v1), …, Z(vk)) 1  2(Z) = 1 (Z)  2(Z) 1  2(Z) = 1 (Z)  2(Z) Negation, quantification, . . .

Meaning of a Formula  (v,v1,v2)  n(v1,v)  n(v2,v)  v1  v2 y x  (v,v1,v2)  n(v1,v)  n(v2,v)  v1  v2 Z = { v  u2, v1  u1, v2  u3} (Z) = n(v1,v)  n(v2,v)  v1  v2(Z) = n(u1, u2)  n(u3, u2)  u1  u3 = 1  1  1 = 1

Outline Using logic to describe stores Using logic to express store transformations Forming abstractions of stores Three-valued logic Using three-valued logic to express transformations of abstract stores

Using Logic to Change Stores x = null Before: x u3 u1 u2 y z After: u3 u1 u2 y z x

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: u3 u1 u2 x[x = null](v)  0

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: u3 u1 u2 y y[x = null](v)  y(v)

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: u3 u1 u2 y z z[x = null](v)  z(v)

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: y u1 u2 z u3

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: y u1 u2 z u3 n[x = null](v1,v2)  n(v1,v2) n n

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: y u1 u2 z u3 n n

Predicate-Alteration Formulas for x = null Old: x u3 u1 u2 y z New: y u1 u2 z u3 n

Outline Using logic to describe stores Using logic to express store transformations Forming abstractions of stores Three-valued logic Using three-valued logic to express transformations of abstract stores

The Abstraction Principle u1 u2 u3 u4 x u1 u234 x Summary Information {0,1}

The Abstraction Principle u1 u2 u3 u4 x u1 u234 x

The Abstraction Principle Select some subset A of the predicate symbols Partition the individuals US of structure S into equivalence classes based on the values of their A predicates u  [u]A Form the “union-quotient” of S with respect to {[u]A | u  US}

Example A = {v | v is a program variable} [Chase, Wegman, & Zadeck 90] [Sagiv, Reps, & Wilhelm 96, 98] u1 u2 u3 u4 x [u1] x [u2] Quotient w.r.t. {w, x, y, z}

Outline Using logic to describe stores Using logic to express store transformations Forming abstractions of stores Three-valued logic Using three-valued logic to express transformations of abstract stores

Two- vs. Three-Valued Logic 1 Two-valued logic {0,1} {0} {1} Three-valued logic {0} 3 {0,1} {1} 3 {0,1}

Two- vs. Three-Valued Logic Two-valued logic Three-valued logic {1} {0,1} {0} 1  1

First-Order Logic (Semantics) Truth values: 0, 1,  Logical structures Individuals: U = {u1, u2, . . ., un} Predicates: pi : U arity(pi)  {0, 1, } In Our Application 3-valued logical structures = Abstract stores

The Abstraction Principle Select some subset A of the predicate symbols Partition the individuals US of structure S into equivalence classes based on the values of their A predicates u  [u]A Form the “union-quotient” of S with respect to {[u]A | u  US}

Abstraction Conserves Predicates S# = S/[u]A S Abs(A) u  [u]A pS (u1, …, uk) 3 pS# ([u1]A, …, [uk]A) “Form the ‘union-quotient’ of S with respect to {[u]A | u  US}”

pS (u1,…,uk) 3 pS# ([u1]A,…,[uk]A) x [u2] u1 u2 u3 u4 x

pS (u1,…,uk) 3 pS# ([u1]A,…,[uk]A) x [u2] u1 u2 u3 u4 x

Abstraction Conserves Properties S# = S/[u]A S Abs(A) u  [u]A pS (u1, …, uk) 3 pS# ([u1]A, …, [uk]A)  S (u1, …, uk) 3  S# ([u1]A, …, [uk]A) Evaluating a formula extracts information conservatively

 S (u1, …, uk) 3  S# ([u1]A, …, [uk]A)   [u1] x [u2] u1 u2 u3 u4 x   (v)   v1,v2 : n(v1,v)  n(v2,v)  v1  v2 1  For  S#([u2]), let v1 = [u1], and v2 = [u2] =  

“Tracking Properties” Beats “Inferring Properties” [u1] x [u2] u1 u2 u3 u4 x

“Tracking Properties” Beats “Inferring Properties” [u1] x [u2] u1 u2 u3 u4 x pS (u1, …, uk) 3 pS# ([u1]A, …, [uk]A) pS (u1, …, uk) 3 pS# ([u1]A, …, [uk]A) pS (u1, …, uk) = pS (u1, …, uk) 3 pS# ([u1]A, …, [uk]A) 3 pS# ([u1]A, …, [uk]A)

Outline Using logic to describe stores Using logic to express store transformations Forming abstractions of stores Three-valued logic Using three-valued logic to express transformations of abstract stores

“Rational reconstruction” of [Chase, Wegman, & Zadeck 90] Example y x [u1] [u2] x y [u1] [u2] x = y  n “Rational reconstruction” of [Chase, Wegman, & Zadeck 90]

Example (~[CWZ 90]) x[x = y  n](v)   v1 : y(v1)  n(v1,v)   [u1] [u2] [u1] [u2] x[x = y  n](v)   v1 : y(v1)  n(v1,v) 1   

Example (~[CWZ 90]) x[x = y  n](v)   v1 : y(v1)  n(v1,v) [u1] [u2] [u1] [u2] x[x = y  n](v)   v1 : y(v1)  n(v1,v) y[x = y  n](v)  y(v) 1

Example (~[CWZ 90]) x[x = y  n](v)   v1 : y(v1)  n(v1,v) [u1] [u2] [u1] [u2] x[x = y  n](v)   v1 : y(v1)  n(v1,v) y[x = y  n](v)  y(v) n[x = y  n](v1,v2)  n(v1,v2) 

Example (~[CWZ 90]) x[x = y  n](v)   v1 : y(v1)  n(v1,v) [u1] [u2] [u1] [u2] x[x = y  n](v)   v1 : y(v1)  n(v1,v) y[x = y  n](v)  y(v) n[x = y  n](v1,v2)  n(v1,v2) 

Example (~[CWZ 90]) x[x = y  n](v)   v1 : y(v1)  n(v1,v) [u1] [u2] [u1] [u2] x[x = y  n](v)   v1 : y(v1)  n(v1,v) y[x = y  n](v)  y(v) n[x = y  n](v1,v2)  n(v1,v2) is[x = y  n](v)  is(v)

[Chase, Wegman, & Zadeck 90] Materialization [Chase, Wegman, & Zadeck 90] y x [u1] [u2] x y [u1] [u2] x = y  n x = y  n [Sagiv, Reps, & Wilhelm 96, 98] x y [u1] [u2] [u3]

(1) Triplicate the Structure x[x = y  n](v)   v1 : y(v1)  n(v1,v) x     y [u1] [u1] [u2] x y x y [u1] [u2.1] x y [u1] [u2.1] [u2.0]

(2) Evaluate Predicate-Alteration Formulas x[x = y  n](v)   v1 : y(v1)  n(v1,v) x y [u1] y [u1] x [u1] [u2.1] x y y [u1] [u2.1] x x y y [u1] [u2.1] [u2.0] [u1] [u2.1] [u2.0]

Additional Abstraction Predicates reachable-from-variable-x(v) acyclic-along-dimension-d(v) à la ADDS doubly-linked(v) tree(v) dag(v) AVL trees: balanced(v), left-heavy(v), right-heavy(v) . . . but not via height arithmetic Need FO + TC

Formalizing “. . .” Informal: x y Formal: x y

Formalizing “. . .” Informal: t1 x y t2 Formal: x y t2 t1

Formalizing “. . .” Informal: Formal: x y x y reachable from variable x variable y

Formalizing “. . .” Informal: t1 t2 Formal: t1 t2 x y x y {x} {x} {t2,y} {t2,y}

Summary Parametric framework Three-valued logic arises from abstraction Three-valued logic also allows: Materialization Conservative extraction of properties Interpretation of program conditions Simpler proofs