Static and User-Extensible Proof Checking Antonis StampoulisZhong Shao Yale University POPL 2012.

Slides:



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

An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Comparing Semantic and Syntactic Methods in Mechanized Proof Frameworks C.J. Bell, Robert Dockins, Aquinas Hobor, Andrew W. Appel, David Walker 1.
Certified Typechecking in Foundational Certified Code Systems Susmit Sarkar Carnegie Mellon University.
Proofs and Programs Wei Hu 11/01/2007. Outline  Motivation  Theory  Lambda calculus  Curry-Howard Isomorphism  Dependent types  Practice  Coq Wei.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Foundational Certified Code in a Metalogical Framework Karl Crary and Susmit Sarkar Carnegie Mellon University.
Current Techniques in Language-based Security David Walker COS 597B With slides stolen from: Steve Zdancewic University of Pennsylvania.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
March 4, 2005Susmit Sarkar 1 A Cost-Effective Foundational Certified Code System Susmit Sarkar Thesis Proposal.
1 Dependent Types for Termination Verification Hongwei Xi University of Cincinnati.
Formal Semantics of Programming Languages 虞慧群 Topic 5: Axiomatic Semantics.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
CS 355 – Programming Languages
Automated Soundness Proofs for Dataflow Analyses and Transformations via Local Rules Sorin Lerner* Todd Millstein** Erika Rice* Craig Chambers* * University.
VeriML: Revisiting the Foundations of Proof Assistants Zhong Shao Yale University MacQueen Fest May 13, 2012 (Joint work with Antonis Stampoulis)
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
CLF: A Concurrent Logical Framework David Walker Princeton (with I. Cervesato, F. Pfenning, K. Watkins)
1 CPS Transform for Dependent ML Hongwei Xi University of Cincinnati and Carsten Schürmann Yale University.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
PROOF TRANSLATION AND SMT LIB CERTIFICATION Yeting Ge Clark Barrett SMT 2008 July 7 Princeton.
Doaitse Swierstra Atze Dijkstra Doaitse Swierstra Atze Dijkstra Type Systems.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
After today Week 9 –Tu: Pat Rondon –Th: Ravi/Nathan Week 10 –Tu: Nathan/Ravi –Th: Class canceled Finals week –Th: Zach, John.
Semantics for MinML COS 441 Princeton University Fall 2004.
Extensible Untrusted Code Verification Robert Schneck with George Necula and Bor-Yuh Evan Chang May 14, 2003 OSQ Retreat.
Extensible Code Verification Kun Gao (Senior EECS) with Professor George Necula, Evan Chang, Robert Schneck, Adam Chlipala An individual receives code.
Formal Methods 1. Software Engineering and Formal Methods  Every software engineering methodology is based on a recommended development process  proceeding.
Have Your Verified Compiler And Extend It Too Zachary Tatlock Sorin Lerner UC San Diego.
VeriML DARPA CRASH Project Progress Report Antonis Stampoulis October 5 th, 2012 A language-based, dependently-typed, user-extensible approach to proof.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
NummSquared Coercion make it so! Samuel Howse poohbist.com November 29, 2006 Copyright © 2006 Samuel Howse. All rights reserved.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
1 MVD 2010 University of Iowa New York University Comparing Proof Systems for Linear Real Arithmetic Using LFSC Andrew Reynolds September 17, 2010.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
An overview of Coq Xinyu Feng USTC Erasmus Mundus NordSecMob Scholar at DTU.
Towards Automatic Verification of Safety Architectures Carsten Schürmann Carnegie Mellon University April 2000.
Logic in Computer Science - Overview Sep 1, 2009 박성우.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Ivan Lanese Computer Science Department University of Bologna/INRIA Italy Decidability Results for Dynamic Installation of Compensation Handlers Joint.
Tool Support for proof Engineering Anne Mulhern Computer Sciences Department University of Wisconsin-Madison Madison, WI USA
Implementing a Dependently Typed λ -Calculus Ali Assaf Abbie Desrosiers Alexandre Tomberg.
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.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
All-Path Reachability Logic Andrei Stefanescu 1, Stefan Ciobaca 2, Radu Mereuta 1,2, Brandon Moore 1, Traian Serbanuta 3, Grigore Rosu 1 1 University of.
CMSC 330: Organization of Programming Languages Lambda Calculus and Types.
SAFE KERNEL EXTENSIONS WITHOUT RUN-TIME CHECKING George C. Necula Peter Lee Carnegie Mellon U.
Carnegie Mellon Vadim Zaliva, Franz Franchetti Carnegie Mellon University Department of Electrical and Computer Engineering Funded by the DARPA I2O HACMS.
Interface specifications At the core of each Larch interface language is a model of the state manipulated by the associated programming language. Each.
Computer Systems Laboratory Stanford University Clark W. Barrett David L. Dill Aaron Stump A Framework for Cooperating Decision Procedures.
Certifying and Synthesizing Membership Equational Proofs Patrick Lincoln (SRI) joint work with Steven Eker (SRI), Jose Meseguer (Urbana) and Grigore Rosu.
1 Interactive Computer Theorem Proving CS294-9 November 30, 2006 Adam Chlipala UC Berkeley Lecture 14: Twelf.
1 Interactive Computer Theorem Proving CS294-9 October 19, 2006 Adam Chlipala UC Berkeley Lecture 9: Beyond Primitive Recursion.
Thoughts on Programming with Proof Assistants Adam Chlipala University of California, Berkeley PLPV Workshop.
Lecture 11: Proof by Reflection
Types for Programs and Proofs
Sparkle a functional theorem prover
A Verified Compiler for an Impure Functional Language
Jared Davis The University of Texas at Austin April 6, 2006
Jared Davis CyberTrust Meeting March 1, 2006
Programming Languages and Compilers (CS 421)
An overview of Coq Xinyu Feng USTC.
An overview of Coq.
Presentation transcript:

Static and User-Extensible Proof Checking Antonis StampoulisZhong Shao Yale University POPL 2012

Proof assistants are becoming popular in our community —CompCert [Leroy et al.] —seL4 [Klein et al.] —Four-color theorem [Gonthier et al.] —1 to 1.5 weeks per paper proof page —4 pages of formal proof per 1 page of paper proof … but they’re still hard to use [Asperti and Coen ‘10]

—communicated to a fixed proof checker —must spell out all details —use domain-specific lemmas Formal proofs —communicated to a person —rely on domain- specific intuition —use “obviously” Informal proofs calculus linear algebra arithmetic

—procedures that produce proofs —domain-specific tactics good in large developments —but difficult to write! We need tactics to omit details -untyped -proofs within tactics can be wrong! -untyped -proofs within tactics can be wrong!

Proof assistants are hard to use because 1. cannot extend proof checker → lots of details 2. no checking for tactics → lots of potential errors These are architectural issues

Our contribution: A new architecture for proof assistants 1. cannot extend proof checker → lots of details 2. no checking for tactics → lots of potential errors 1. extensible proof checker → omit lots of details 2. extensible checking for tactics → lots of errors avoided static checking of contained proofs full programming model soundness guaranteed full programming model soundness guaranteed More specifically: -a new language design -a new implementation -and a new metatheory based on VeriML [ICFP’10] “intuition” stack arithmetic congruence βι- conversion

Architecture of proof assistants

Architecture of proof assistants: main notions Derivation in a logic Proof object Checks proof objects Proof checker Function producing proof objects Tactic Combination of tactics; program producing a proof object Proof script

Architecture of proof assistants: Checking proof objects Proof object Proof checker Conversion rule Implicitly check equivalences (proof omitted) Conversion rule Implicitly check equivalences (proof omitted)

Architecture of proof assistants: Checking proof objects Proof object Proof checker Coq βι-conversion Coq βι-conversion

Architecture of proof assistants: Checking proof objects Proof object Proof checker CoqMT βι-conversion + linear arithmetic CoqMT βι-conversion + linear arithmetic

Architecture of proof assistants: Checking proof objects Proof object Proof checker -rich static information -(de)composable -checking not extensible

Architecture of proof assistants: Validating proof scripts Proof script Proof checker Proof object evaluation -extensible through tactics -rich programming model -no static information -not (de)composable -hidden proof state use conversion for more robust scripts Arithmetic tactic User tacticOther tactic

Moving to typed proof scripts Typed proof script Type checker Proof script Proof object Proof checker evaluation Proof checker Arithmetic tactic User tacticOther tactic Arithmetic tactic User tacticOther tactic evaluation

Moving to typed proof scripts + extensible conversion Typed proof script Type checker Proof checker evaluation Arithmetic tactic User tactic Other tactic Key insight: conversion is just a hardcoded trusted tactic Key insight: conversion is just a hardcoded trusted tactic but we can trust other tactics too if they have the right type

Moving to typed proof scripts + extensible conversion Typed proof script evaluation Key insight: conversion is just a hardcoded trusted tactic Key insight: conversion is just a hardcoded trusted tactic but we can trust other tactics too if they have the right type Type checker Proof checker none of them needs to be hardcoded! Type checker Proof checker Other tactic

Typed proof scripts + extensible conversion Typed proof script evaluation Type checker Proof checker -rich static information -user chooses conversion -extensible static checking -smaller proof checker -can generate proof objects

Type checking tactics: an example -check propositions for equivalence -return a proof if they are -raise an exception otherwise Metatheory result 1. Type safety If evaluation succeeds, the returned proof object is valid Metatheory result 1. Type safety If evaluation succeeds, the returned proof object is valid Metatheory result 2. Proof erasure If evaluation succeeds, a valid proof object exists even if it’s not generated Metatheory result 2. Proof erasure If evaluation succeeds, a valid proof object exists even if it’s not generated

Two modes of evaluation evaluation proof object proof object proof erasure evaluation proof erasure evaluation mode controlled per function Typed proof script Type checker Proof checker

Typed proof script Type checker evaluation Proof checker Static checking = type checking + staging under proof-erasure typechecking stage-one evaluation with proof erasure evaluation of residual program

A stack of conversion rules arithmetic simplification congruence closure βι-conversion conversion in Coq removed from trusted base conversion in Coq removed from trusted base makes most uses of rewrite/autorewrite unnecessary ring_simplify for Nat close to CoqMT ring_simplify for Nat close to CoqMT no additions to logic metatheory actually, with reductions no proof by reflection or translation validation leveraging static proof scripts no additions to logic metatheory actually, with reductions no proof by reflection or translation validation leveraging static proof scripts

A stack of conversion rules arithmetic simplification naïve arithmetic conversion congruence closure naïve equality conversion βι- conversion potentially non- terminating reduce proving for “real” versions potentially non- terminating reduce proving for “real” versions

Static proof scripts in tactics

Require Import Arith. Variable x : Nat. Theorem test1 : 0 + x = x. trivial. Qed. Theorem test2 : x + 0 = x. trivial. Qed. Motivating Coq Example

Require Import Arith. Variable x : Nat. Theorem test1 : 0 + x = x. trivial. Qed. Theorem test2 : x + 0 = x. trivial. Qed. Motivating Coq Example Proof completed

Require Import Arith. Variable x : Nat. Theorem test1 : 0 + x = x. trivial. Qed. Theorem test2 : x + 0 = x. trivial. Qed. Motivating Coq Example Attempt to save an incomplete proof

Require Import Arith. Variable x : Nat. Theorem test1 : 0 + x = x. trivial. Qed. Theorem test2 : x + 0 = x. trivial. Qed. Motivating Coq Example Conversion rule can prove this but can’t prove this

Let’s add this to our conversion rule! -write a rewriter based on these lemmas -register it with conversion -now it’s trivial; lemmas used implicitly

not checked statically recomputed many times not checked statically recomputed many times similar to trivial uses conversion P and P’ inferred similar to trivial uses conversion P and P’ inferred

checked at definition time computed once transformation of runtime arguments to constant arguments checked at definition time computed once transformation of runtime arguments to constant arguments

How does it work?

Implementation type inferencing and implicit arguments compiler to OCaml rewriter code generation inductive types Talk to me for a demo!

What’s in the paper and TR Static and dynamic semantics Metatheory: Type-safety theorem Proof erasure theorem Static proof script transformation Implementation details and examples implemented Typed proof scripts as flexible proof certificates

Related work proof-by-reflection – restricted programming model (total functions) – tedious to set up – here: no need for termination proofs automation through canonical structures / unification hints – restricted programming model (logic programming) – very hard to debug

Summary a new architecture for proof assistants user-extensible checking of proofs and tactics minimal trusted core reduce required effort for formal proofs Thanks!

Backup slides

Type checking proofs and tactics Type checker Proof checker -manipulate proofs and propositions in a type-safe manner -dependent pattern matching on logical terms -logic and computation are kept separate -Beluga [Pientka & Dunfield ‘08] -Delphin [Poswolsky & Schürmann ‘08] -VeriML [Stampoulis & Shao ‘10]

Related work LCF family of proof assistants – no information while writing proof scripts/tactics Coq / CoqMT – conversion rule is fixed – changing it requires re-engineering NuPRL – extensional type theory and sophisticated conversion – here: user decides conversion (level of undecidability) Beluga / Delphin – use as metalogic for LF – here: the logic is fixed; the language is the proof assistant