Relatively Complete Verification of Higher- Order Programs (via Automated Refinement Type Inference) Tachio Terauchi Nagoya University TexPoint fonts used.

Slides:



Advertisements
Similar presentations
A practical and complete approach to predicate abstraction Ranjit Jhala UCSD Ken McMillan Cadence Berkeley Labs.
Advertisements

Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Quantified Invariant Generation using an Interpolating Saturation Prover Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Software Model Checking with SMT Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A.
Predicate Abstraction and Canonical Abstraction for Singly - linked Lists Roman Manevich Mooly Sagiv Tel Aviv University Eran Yahav G. Ramalingam IBM T.J.
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
Verifying Executable Object-Oriented Specifications with Separation Logic Stephan van Staden, Cristiano Calcagno, Bertrand Meyer.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
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.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Automating Relatively Complete Verification of Higher-Order Functional Programs Hiroshi Unno (University of Tsukuba) Tachio Terauchi (Nagoya University)
Logic as the lingua franca of software verification Ken McMillan Microsoft Research TexPoint fonts used in EMF: A A A A A Joint work with Andrey Rybalchenko.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
ISBN Chapter 3 Describing Syntax and Semantics.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
Probabilistic CEGAR* Björn Wachter Joint work with Holger Hermanns, Lijun Zhang TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
What’s left in the course. The course in a nutshell Logics Techniques Applications.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
C. FlanaganSAS’04: Type Inference Against Races1 Type Inference Against Races Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College.
1 Predicate Abstraction of ANSI-C Programs using SAT Edmund Clarke Daniel Kroening Natalia Sharygina Karen Yorav (modified by Zaher Andraus for presentation.
Administrative stuff On Thursday, we will start class at 11:10, and finish at 11:55 This means that each project will get a 10 minute presentation + 5.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Describing Syntax and Semantics
Invisible Invariants: Underapproximating to Overapproximate Ken McMillan Cadence Research Labs TexPoint fonts used in EMF: A A A A A.
Cormac Flanagan University of California, Santa Cruz Hybrid Type Checking.
Equational Reasoning Math Foundations of Computer Science.
Cristian Gherghina Joint work with: Wei-Ngan Chin, Razvan Voicu, Quang Loc Le Florin Craciun, Shengchao Qin TexPoint fonts used in EMF. Read the TexPoint.
Crowfoot: a verifier for higher order store programs Billiejoe (Nathaniel) Charlton Ben Horsfall Bernhard Reus University of Sussex VMCAI 2012.
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
1 Automatic Refinement and Vacuity Detection for Symbolic Trajectory Evaluation Orna Grumberg Technion Haifa, Israel Joint work with Rachel Tzoref.
Refinement Type Inference via Horn Constraint Optimization Kodai Hashimoto and Hiroshi Unno (University of Tsukuba, Japan)
A Template-based Approach to Complete Predicate Refinement Tachio Terauchi (Nagoya University) Hiroshi Unno (University of Tsukuba) Naoki Kobayashi (University.
Race Checking by Context Inference Tom Henzinger Ranjit Jhala Rupak Majumdar UC Berkeley.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Checking Reachability using Matching Logic Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
From Hoare Logic to Matching Logic Reachability Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
Automated tactics for separation logic VeriML Reconstruct Z3 Proof Safe incremental type checker Certifying code transformation Proof carrying hardware.
SMT and Its Application in Software Verification (Part II) Yu-Fang Chen IIS, Academia Sinica Based on the slides of Barrett, Sanjit, Kroening, Rummer,
Generating High-Quality Tests for Boolean Circuits by Treating Tests as Proof Encoding Eugene Goldberg, Pete Manolios Northeastern University, USA TAP-2010,
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.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
CHARME’03 Predicate abstraction with Minimum Predicates Sagar Chaki*, Ed Clarke*, Alex Groce*, Ofer Strichman** * Carnegie Mellon University ** Technion.
Boolean Programs: A Model and Process For Software Analysis By Thomas Ball and Sriram K. Rajamani Microsoft technical paper MSR-TR Presented by.
An algorithmic proof of the Lovasz Local Lemma via resampling oracles Jan Vondrak IBM Almaden TexPoint fonts used in EMF. Read the TexPoint manual before.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Counterexample-Guided Abstraction Refinement By Edmund Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith Presented by Yunho Kim Provable Software.
Mostly-Automated Verification of Low-Level Programs in Computational Separation Logic Adam Chlipala Harvard University PLDI 2011.
The software model checker BLAST Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala, Rupak Majumdar Presented by Yunho Kim TexPoint fonts used in EMF. Read.
Lesson 10 Type Reconstruction
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Automating Induction for Solving Horn Clauses
MoCHi: Software Model Checker for a Higher-Order Functional Language
Lesson 4 Typed Arithmetic Typed Lambda Calculus
Stateful Manifest Contracts
Relatively Complete Refinement Type System for Verification of Higher-Order Non-deterministic Programs Hiroshi Unno (University of Tsukuba) Yuki Satake.
Inferring Simple Solutions to Recursion-free Horn Clauses via Sampling
Husam Abu-Haimed David L. Dill Sergey Berezin
Over-Approximating Boolean Programs with Unbounded Thread Creation
Presentation transcript:

Relatively Complete Verification of Higher- Order Programs (via Automated Refinement Type Inference) Tachio Terauchi Nagoya University TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A AA A A A A A

Verifying higher-order functional programs let rec F x c = c x in and G x y = assert x+1 ¸ y; F (y+1) (G y) in and Main w = F (w+1) (G w) Show : 8 w:int. Main w is assertion safe Refinement types approach: F : x:int -> c:({u|u ¸ x} -> *) -> * G : x:int -> y:{u|x+1 ¸ y} -> * Main: w:int -> *

Much recent work on automated inference Liquid types [Rondon, Kawaguchi, Jhala PLDI’08] Dependent type inference with interpolants [Unno, Kobayashi PPDP’09] Dependent types from counterexamples [Terauchi POPL’10] Predicate abstraction and CEGAR for higher-order model checking [Kobayashi, Sato, Unno PLDI’11] HMC: Verifying functional programs using abstract interpreters [Jhala, Majumdar, Rybalchenko CAV’11] “?” [Jagannathan 2011] Leverages advances in first-order program verification: –predicate abstraction, interpolation, CEGAR, SMT solvers, Test generation, etc. “Model Checkers” for higher-order programs Incomplete

Completeness and Incompleteness Def: Refinement type system is sound iff –If a program is typable then it is safe. Def: Refinement type system is complete iff –A program is typable iff it is safe. Existing refinement type systems are sound, but incomplete –Different from incompleteness of inference algorithms

Relative Completeness Higher-order program verification is undecidable –Because it contains 1 st -order program verification Complete verification for 1 st -ord programs –E.g., Hoare logic –Relative to expressive 1 st -ord theory like PA Allow arbitrary PA formulas as refinement predicates? i.e., { u | µ } µ 2 PA –Sufficient for ord-1 programs –Not for general higher-order programs

Refinement types incompleteness in detail Problem: Higher-order functions A typical relative completeness proof of Hoare logic –wpre(x = e, µ ) = µ [x/e] –wpre(s 1 ;s 2, µ ) = wpre(s 1,wpre(s 2, µ )), … –Show the logic (PA) can express wpre(…) –Then, s is safe iff wpre(s,true) = true. What’s wpre(f x, µ ) where f : int -> * and x : int? Or wpre(g f, µ ) with g : (int -> *) -> * and f : (int -> *)?

Weakest pre. of higher-order terms Ideally: –wpre(f x, true) = “f x runs safe” –Ex. F f x = f x F : f:(int->*)->x:{ u : int | “f u runs safe” }->* –But, ref. pred. inference becomes higher-order program verification! –To prevent circularity, we only allow 1 st -ord formulas I don’t have relative completeness for all higer-order programs yet  I will show: How to get relative completeness for a class that haven’t been covered previously

Closure Boudedness Def: Size of a closure is the number of base-type values captured in the closure Def: A program is closure-bounded if its evaluation only generates closures of bounded size Def: Closure pattern is a closure with base-type values abstracted –E.g., F (G ® ) ® represent infinite number of closures F (G 0) 0, F (G 0) 1, F (G 1) -1, … –In lambda, ¸ x.(y ( ¸ z.z ® ) ® ), etc. Lemma: Closure-bounded iff finite # of patterns

Contribution Relative completeness for closure-bounded programs High-level Idea : Environment Passing F c f = c f G x k = k x H x y = assert x · y; F (G y+1) (H y) Main w = F (G w+1) (H w) Parametrize type of F with G ®, H ® F : 8 a 1. 8 a 2.c:(({u| µ1 }->*)->*)->f:({u| µ2 } ->*) ->* Intersection types to handle different contexts (this example needs none) Show: 8 w:int. Main w as safe

Details Naïve Approach : –Symbolically evaluate the program for n steps and record closure patterns seen –Build type shapes from the patterns –Check if typable restricted to the type shapes –If not typable, increase n and repeat –(In parallel) check for unsafety

Symbolic Eval => Closure Patterns Patterns A := F | ® | F A –Ex. Evaluate from M with w : int Patterns: F (G ® ) ®, … F c x = c x G x y = assert x+1 · y ; F (G y) (y+1) M w = F (G w) (w+1)

Patterns => Type shapes Types t := * | x:t -> t | {u| µ } | 8 x.t | [A].t Æ [A].t Type shapes = N £ types with µ erased –E.g., (3, f:{u|_}->*) ord(A) = order of simple type of A A => (v,t’) inductively on the order of A –Ex. A = F : –Seen patterns: F (G ® ) ®, F (H ® ® ) ®, … –ty(F) = (0, [(G ® ), ® ]. 8 a1.t1-> ®.s->* Æ [(H ® ® ), ® ]. 8 a1 8 a2.t2-> ®.s->*) –ty( ® ) = (0,s), ty(G ® ) = (1,t1), ty(H ® ® ) = (2, t2), …

Checking typability Shapes & patterns => derivation structure –For each F, have patterns A 1, …, A n for its args –Make type derivation per F, A i –Ex. Patterns : F (G ® ) (K ® ) ® for F c f x = c f x Track concrete patterns: c: G a1, f: K a2, x: x, …, up to base-type parameter variables At function applications –Look up ty(...) for matching abstract patterns –Instantiate with captured base-type variables –Use “top” type to handle unmatched shapes Infer satisfying assignment for µ ’s –If none found, fail

Summary of naïve approach Symbolically evaluate the program for n steps and record closure patterns seen Build type shapes from the patterns Check if typable restricted to the type shapes If not typable, increase n and repeat (In parallel) check for unsafety Thm: This is rel. comp. for closure-bounded programs –Pf. Like that of Hoare logic. “Thread” weakest precondition through the type derivation. Cor: 1 st -order program verification can be “lifted” to closure-bounded higher-order program verification

Naïve approach Relatively complete but not very clever –Patterns sufficient but not always necessary –Fails for non-closure-bounded programs Better approach: –Try type inference w/o patterns –If type inference fails, then infer patterns –Repeat with the added patterns –Also, just add candidate 8 x.t, e[e’] and have type inf. alg. figure out the rest (i.e., rid patterns from type inference)

Check typability w/o patterns Leverage existing algorithms –Liquid types [Rondon, Kawaguchi, Jhala PLDI’08] –Dependent type inference with interpolants [Unno, Kobayashi PPDP’09] –Dependent types from counterexamples [Terauchi POPL’10] –Predicate abstraction and CEGAR for higher-order model checking [Kobayashi, Sato, Unno PLDI’11] –HMC: Verifying functional programs using abstract interpreters [Jhala, Majumdar, Rybalchenko CAV’11]

A)Use the symbolic evaluation as in naïve B)Or use counterexample from type inference [Terauchi POPL’10][Kobayashi, Sato, Unno PLDI’11] –Unwound program slice without recursion –Infer patterns that occur in slice via flow analysis If inference fails, infer patterns

Check typability with the added patterns Like the naïve approach, but Instead of using the patterns –i.e., c : G w, …, and [(G ® ), ® ]. 8 x.t1-> ®.s->*, …, etc. Use the built type shapes minus the patterns –c : 8 x.{u | _} -> *, … –And how to instantiate them –Let backend type inference alg. resolve type matching (as well as µ inference) Implement as program translation

Program Translation Universal types 8 x.t modeled by x:int -> t Instantiations e[e’] modeled by e e’ F c f = c f G x k = k x H x y = assert x · y main w = F (G w) (H w) F a 1 a 2 c f = c f G x k = k x H x y = assert x · y main w = F w (G w) w (H w) ty(F) = (nil, 8 a 1. 8 a 2.c:(({u|_}->*)->*)->f:({u|_} ->*) ->*) ty(G ® ) = ([w],…) ty(H ® ) = ([w],…) Multiple trans. when ty(…) has intersection types (none needed for this example)

Summary of translation approach Try type inference w/o patterns If type inference fails, then infer patterns Repeat with the added patterns Uses off-the-shelf refinement type inference algorithms Complete relative to –Underlying refinement type inference And pattern generation –Incomplete in practice (obviously)

Preliminary Experimental Results Depcegar [Terauchi POPL’10]

Conclusions Relatively complete verification framework for higher-order programs –Based on refinement types –Good for “model checking” like automation Frees the backend theorem prover/decision prover from directly reasoning about higher-order functions –High-level : Environment passing –Theory : Rel. comp. for closure-bounded programs –Practice: Iterative translation