Types, Proofs, and Safe Mobile Code The unusual effectiveness of logic in programming language research Peter Lee Carnegie Mellon University January 22,

Slides:



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

Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Static and User-Extensible Proof Checking Antonis StampoulisZhong Shao Yale University POPL 2012.
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.
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.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 20: Total Correctness; Proof-
March 4, 2005Susmit Sarkar 1 A Cost-Effective Foundational Certified Code System Susmit Sarkar Thesis Proposal.
Nicholas Moore Bianca Curutan Pooya Samizadeh McMaster University March 30, 2012.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
VIDE als voortzetting van Cocktail SET Seminar 11 september 2008 Dr. ir. Michael Franssen.
Lectures on Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 2 (of 3) June 21-22, 2003 University of Oregon 2004 Summer School on Software.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
An Introduction to Proof-Carrying Code David Walker Princeton University (slides kindly donated by George Necula; modified by David Walker)
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
Code-Carrying Proofs Aytekin Vargun Rensselaer Polytechnic Institute.
Catriel Beeri Pls/Winter 2004/5 last 55 Two comments on let polymorphism I. What is the (time, space) complexity of type reconstruction? In practice –
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)
PROOF TRANSLATION AND SMT LIB CERTIFICATION Yeting Ge Clark Barrett SMT 2008 July 7 Princeton.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
1 A Dependently Typed Assembly Language Hongwei Xi University of Cincinnati and Robert Harper Carnegie Mellon University.
Programmability with Proof-Carrying Code George C. Necula University of California Berkeley Peter Lee Carnegie Mellon University.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Language-Based Security Proof-Carrying Code Greg Morrisett Cornell University Thanks to G.Necula & P.Lee.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Lectures on Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 1 (of 3) June 21-22, 2003 University of Oregon 2004 Summer School on Software.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
A Type System for Expressive Security Policies David Walker Cornell University.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
Extensible Untrusted Code Verification Robert Schneck with George Necula and Bor-Yuh Evan Chang May 14, 2003 OSQ Retreat.
1 The Problem o Fluid software cannot be trusted to behave as advertised unknown origin (must be assumed to be malicious) known origin (can be erroneous.
1 Type-Directed Concurrency Deepak Garg, Frank Pfenning {dg+, Carnegie Mellon University.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 1 Course Overview July 10, 2001 Lipari School on Foundations of.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Software Models (Cont.) 9/22/2015ICS 413 – Software Engineering1 -Component-based software engineering -Formal Development Model.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Proof-Carrying Code & Proof-Carrying Authentication Stuart Pickard CSCI 297 June 2, 2005.
Dichotomies: Software Research vs Practice Peter Lee Carnegie Mellon University HCMDSS Workshop, June 2005 Peter Lee Carnegie Mellon University HCMDSS.
Ethan Jackson, Nikolaj Bjørner and Wolfram Schulte Research in Software Engineering (RiSE), Microsoft Research 1. A FORMULA for Abstractions and Automated.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 3 July 12, 2001 VC Generation and Proof Representation Lipari.
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.
© Andrew IrelandDependable Systems Group On the Scalability of Proof Carrying Code for Software Certification Andrew Ireland School of Mathematical & Computer.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 2 July 11, 2001 Overview of PCC and Safety Policies Lipari School.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 3 July 12, 2001 VC Generation and Proof Representation Lipari.
Logic in Computer Science - Overview Sep 1, 2009 박성우.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 1 Course Overview July 10, 2001 Lipari School on Foundations of.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Semantics In Text: Chapter 3.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
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.
Automated tactics for separation logic VeriML Reconstruct Z3 Proof Safe incremental type checker Certifying code transformation Proof carrying hardware.
11 Artificial Intelligence CS 165A Thursday, October 25, 2007  Knowledge and reasoning (Ch 7) Propositional logic 1.
Computer Science at Carnegie Mellon Freshman IC Peter Lee Professor and Associate Dean.
SAFE KERNEL EXTENSIONS WITHOUT RUN-TIME CHECKING George C. Necula Peter Lee Carnegie Mellon U.
CSE 60641: Operating Systems George C. Necula and Peter Lee, Safe Kernel Extensions Without Run-Time Checking, OSDI ‘96 –SIGOPS Hall of fame citation:
Artificial Intelligence Logical Agents Chapter 7.
Mobility, Security, and Proof-Carrying Code Peter Lee Carnegie Mellon University Lecture 2 July 11, 2001 Overview of PCC and Safety Policies Lipari School.
Types for Programs and Proofs
Certified Code Peter Lee Carnegie Mellon University
Towards a Unified Theory of Operational and Axiomatic Semantics
Presentation transcript:

Types, Proofs, and Safe Mobile Code The unusual effectiveness of logic in programming language research Peter Lee Carnegie Mellon University January 22, 2001 NSF/CISE Workshop on The Unusual Effectiveness of Logic in Computer Science

Carnegie Mellon Logic in PL research Domain theory Category theory Type theory Term rewriting systems Denotational semantics Operational semantics Formal verification Logic programming Proof-carrying code Type-directed compiling Logic frameworks Logic is the foundation of modern PL research. -calculus Abstract Interpretation

Carnegie Mellon This talk A somewhat personal account, by necessity a rather narrow slice. But similar stories can be found in almost all areas of PL research.

Logic as Language

Carnegie Mellon Logic and languages To PL researchers, logics and languages are often interchangeable. A vivid example of this is in formal proofs. Consider: Write “x is a proof of P” as x:P.

Carnegie Mellon Formal proofs We can write formal proofs by application of inference rules. An example: If we have a proof x of P and a proof y of Q, then x and y together constitute a proof of P  Q. Or, more compactly:  Given x:P, y:Q then (x,y):P*Q.

Carnegie Mellon Formal proofs Another familiar example: Assume we have a proof x of P. If we can then obtain a proof b of Q, then we have a proof of P  Q. Given [x:P] b:Q then fn (x:P) => b : P  Q. More:  Given x:P*Q then fst(x):P  Given y:P*Q then snd(y):Q

Carnegie Mellon Proofs and types So, for example: fn (x:P*Q) => (snd(x), fst(x)) : P*Q  Q*P We can develop full metalanguages based on this principle of proofs as programs, propositions as types. Typechecking gives us proofchecking! Codified in languages such as ML.

Carnegie Mellon Applications This isomorphism has had many applications in logic and in CS. Proof development systems.  NuPrl, Coq, LCF, … Advanced programming languages. Prolog. Logical framework languages.  Edinburgh Logical Framework.

Carnegie Mellon Logical frameworks The Edinburgh Logical Framework (LF) is a particularly useful language for specifying logics.

Carnegie Mellon LF example exp : type pred : type pf : pred -> type true : pred /\ : pred -> pred -> pred => : pred -> pred -> pred all : (exp -> pred) -> pred truei : pf true andi : {P:pred} {R:pred} pf P -> pf R -> pf (/\ P R) andel : {P:pred} {R:pred} pf (/\ P R) -> pf P impi : {P:pred} {R:pred} (pf P -> pf R) -> pf (=> P R) alli : {P:exp -> pred} ({X:exp} pf (P X)) -> pf (all P) alle : {P:exp -> pred} {E:exp} pf (all P) -> pf (P E) Fragment of first-order logic, Pfenning’s Elf syntax.

Carnegie Mellon LF example The representation of P  P  P for some predicate P: The proof of this predicate has the following Elf representation: (=> P (/\ P P )) (impi P (/\ P P ) ([X:pf P ] andi P P x x))

Language as Logic

Carnegie Mellon Languages and logic To PL researchers, languages and logics are often interchangeable. A vivid example of this is in type theory.

Carnegie Mellon Type theory A standard application of type theory involves the following: Operational (run-time) semantics is defined by an inference system. Type system is also defined by an inference system. Logic is used to prove the soundness of the type system wrt the semantics. A programming language is a logic.

Carnegie Mellon Soundness Soundness: Well-typed programs are guaranteed to stay within the boundaries defined by the operational semantics. Well-typed programs won’t go wrong.

Carnegie Mellon Practical benefits Soundness can be hard to prove. But it essentially converts the very difficult negative property (program won’t go wrong) into a positive property (program is well-typed). Only need to prove soundness once.

Carnegie Mellon Applications Current research often involves defining the logical core of a language and then studying its properties. Existing languages.  ML, Haskell, JVML, … New design and implementation features.  Type-directed compiling, region inference, linear typing, …

Proofs, Types, and Safe Mobile Code

Carnegie Mellon The code safety problem Please install and execute this. Full cartoon

Carnegie Mellon Code Safety CPU Code Trusted Host Is this safe to execute?

Carnegie Mellon Theorem Prover Formal verification CPU Code Flexible and powerful. Trusted Host But really really really hard and must be correct.

Carnegie Mellon A Key Idea: Explicit Proofs Certifying Prover CPU Proof Checker Code Proof Trusted Host

Carnegie Mellon Proof-Carrying Code [Necula & Lee, OSDI’96] A B Formal proof safety in LF Typically native or VM code rlrrllrrllrlrlrllrlrrllrrll…

Carnegie Mellon Proof-Carrying Code Certifying Prover CPU Code Proof Simple, small (<52KB), and fast. No longer need to trust this component. Proof Checker Reasonable in size (0-10%).

Carnegie Mellon The Role of Languages and Logic Civilized programming languages can provide “safety for free”. Well-formed/well-typed  safe. Idea: Arrange for the compiler to “explain” why the target code it generates preserves the safety properties of the source program.

Carnegie Mellon Automation via Certifying Compilation Certifying Compiler CPU Looks and smells like a compiler. % spjc foo.java bar.class baz.c -ljdk1.2.2 Source code Proof Object code Certifying Prover Proof Checker

Carnegie Mellon Safety Policies in LF jfloat : exp. jinstof : exp -> exp. of: exp -> exp -> pred. faddf: {E:exp} {E':exp} pf (of E jfloat) -> pf (of E' jfloat) -> pf (of (fadd E E') jfloat). ext: {E:exp} {C:exp} {D:exp} pf (jextends C D) -> pf (of E (jinstof C)) -> pf (of E (jinstof D)). Fragment of rules for the Java type system.

Carnegie Mellon Program checking A proof for (saferd4 (add src_1 (add (imul edx_1 4) 8))) in the Java specification looks like this (excerpt): (rdArray4 A0 A2 (sub0chk A3) szint (aidxi 4 (below1 A7))) This proof can be easily validated via LF type checking.

Themes and Conclusions

Carnegie Mellon Coherence Research in programming languages is largely directed towards achieving coherence in software systems. Main Entry: co·her·ence Pronunciation: kO-'hir-&n(t)s, -'her- Function: noun Date: : the quality or state of cohering: as a : systematic or logical connection or consistency b : integration of diverse elements, relationships, or values 2 : the property of being coherent

Carnegie Mellon Coherence Coherence requires: ability to analyze/verify components, and communicate descriptions of components. Logic is canonical, in the sense of being the only foundation for this.

Carnegie Mellon Esthetics vs. pragmatics Many of the methods and results are motivated as much by esthetic as they are by pragmatic concerns. Practical engineering consequences: Minimality and clarity of expression. Scaling up by study of “core” logics. Can sometimes be divorced from real- world problems, but hard to predict.

Carnegie Mellon Practicality In recent years, a trend towards picking the low-hanging fruit. Eliminate “simple errors”. Exposed by the Web, plug-ins, embedded systems, etc. Even machine languages! Small theorems about big programs.

Carnegie Mellon Conclusions For much of the history of CS, PL research meant design of languages and compiler technology. Today, PL technology and concepts advance logic and are applied directly to software artifacts. “LF in the Unix kernel.”

Carnegie Mellon A logical approach Please install and execute this. OK, but let me quickly look over the instructions first. Code producerHost

Carnegie Mellon A logical approach Code producerHost

Carnegie Mellon A logical approach This store instruction is dangerous! Code producerHost

Carnegie Mellon A logical approach Can you prove that it is always safe? Code producerHost

Carnegie Mellon A logical approach Can you prove that it is always safe? Yes! Here’s the proof I got from my certifying Java compiler! Code producerHost

Carnegie Mellon A logical approach Your proof checks out. I believe you because I believe in logic. Code producerHost return