Lectures on Computational Type Theory

Similar documents
Design Issues for Implemented Type Theories. Robert Constable Cornell University

The Calculus of Inductive Constructions

Bootstrapping Mathematics

Main Issues in Computer Mathematics. Henk Barendregt Brouwer Institute Radboud University Nijmegen, The Netherlands

CS3110 Spring 2017 Lecture 11: Constructive Real Numbers

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg

utomated Reasoning 2 What is automated reasoning? In one sense we'll interpret our title narrowly: we are interested in reasoning in logic and mathema

The LCF Approach to Theorem Proving

Formalizing Mathematics

The Curry-Howard Isomorphism

Is Constructive Logic relevant for Computer Science?

Interactive Theorem Provers

Proof Theory and Subsystems of Second-Order Arithmetic

Logic in Computer Science. Frank Wolter

02 The Axiomatic Method

Automata Theory. Definition. Computational Complexity Theory. Computability Theory

Foundations of Computation. Ana Bove

Computational Logic and the Quest for Greater Automation

CHAPTER 11. Introduction to Intuitionistic Logic

CS3110 Fall 2013 Lecture 11: The Computable Real Numbers, R (10/3)

Computer Proof Assistants and Univalent Foundations of Mathematics

The Legacy of Hilbert, Gödel, Gentzen and Turing

cse371/mat371 LOGIC Professor Anita Wasilewska Fall 2018

De Bruijn s ideas on the Formalization of Mathematics

Introduction to dependent type theory. CIRM, May 30

HoTT seminar organization

Intuitionistic Completeness of First-Order Logic mpc Case

arxiv: v1 [cs.lo] 31 Aug 2014

Chapter 11: Automated Proof Systems

Chapter 1 A computational interpretation of forcing in Type Theory

Lecture 14 Rosser s Theorem, the length of proofs, Robinson s Arithmetic, and Church s theorem. Michael Beeson

On Modal Logics of Partial Recursive Functions

Beyond First-Order Logic

185.A09 Advanced Mathematical Logic

Formal Verification of Mathematical Algorithms

Program Testing and Constructive Validity

Introduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014

Proof assistants: History, ideas and future

Operational Semantics in Languages and Logics

The Formal Proof Susan Gillmor and Samantha Rabinowicz Project for MA341: Appreciation of Number Theory Boston University Summer Term

The semantics of propositional logic

Formalizing Kruskal s Tree Theorem in Isabelle/HOL

Completeness Theorems and λ-calculus

Chapter 11: Automated Proof Systems (1)

Computer-Checked Meta-Logic

Between proof theory and model theory Three traditions in logic: Syntactic (formal deduction)

An Introduction to Proof Assistants

LCF + Logical Frameworks = Isabelle (25 Years Later)

Theorem Proving for Verification

On Building Constructive Formal Theories of Computation Noting the Roles of Turing, Church, and Brouwer

Nonclassical logics (Nichtklassische Logiken)

Should We Teach Formal Methods at All?

Lectures on The Lambda Calculus (I)

Intel s Successes with Formal Methods

The following techniques for methods of proofs are discussed in our text: - Vacuous proof - Trivial proof

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

Computer Science and Logic A Match Made in Heaven

Topology for functional programming

Evidence Semantics and Refinement Rules for First-Order Logics: Minimal, Intuitionistic, and Classical

Contents Propositional Logic: Proofs from Axioms and Inference Rules

Modal homotopy type theory: The new new logic

A Semantics of Evidence for Classical Arithmetic

Foundations for the Management of Formal Mathematical Knowledge

Introduction to Intuitionistic Logic

Propositions as Types

- Introduction to propositional, predicate and higher order logics

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC

Coq as a Metatheory for Nuprl with Bar Induction

M.Burgin Department of Mathematics University of California, Los Angeles Los Angeles, CA 90095

Constructive (functional) analysis

A BRIEF INTRODUCTION TO TYPED PREDICATE LOGIC

cse541 LOGIC FOR COMPUTER SCIENCE

Constructive reverse mathematics: an introduction

Realizable Extensions of Intuitionistic Analysis: Brouwer, Kleene, Kripke and the End of Time

Program Testing and the Meaning Explanations of Intuitionistic Type Theory

Program-ing in Coq. Matthieu Sozeau under the direction of Christine Paulin-Mohring

Chapter 2: Introduction to Propositional Logic

Lecture 1: Logical Foundations

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

07 Practical Application of The Axiomatic Method

Creating Knowledge in the Age of Digital Information

CS 275 Automata and Formal Language Theory

Interactive Theorem Proving in Industry

Handbook of Logic and Proof Techniques for Computer Science

Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison

1. A motivation for algebraic approaches to logics

Extending higher-order logic with predicate subtyping: application to PVS

Constructive analysis

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)

What is a Proof? Jean Gallier and Kurt W.A.J.H.Y. Reillag CIS, Upenn and Hospices de Beaune. Friday, February 22, 13

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012

From syntax to semantics of Dependent Type Theories - Formalized

An Intuitively Complete Analysis of Gödel s Incompleteness

Introduction to Turing Machines

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

CS 275 Automata and Formal Language Theory

Discrete Mathematics

Herbrand Theorem, Equality, and Compactness

Agent-Based HOL Reasoning 1

Transcription:

Lectures on Computational Type Theory From Proofs-as-Programs to Proofs-as-Processes Robert L. Constable Cornell University

Lecture Schedule Lecture 1: Origins and Introduction to Computational Type Theory (CTT) Lecture : Logic in CTT Lecture 3: Proofs as Programs Lecture 4: The Logic of Events and Proofs as Processes

Obsession Since 1971 I ve been obsessed with the connection between formal math and programming languages. I see a convergence. formal computational math PSEs richly typed PLs LPEs

Why Study CTT? 1. CTT is a very rich type theory, slightly older sibling of CIC as implemented in Coq. Here is a comparison: CTT CIC grounded in semantics grounded in proof theory (partial equivalence) (strong normalization) implicitly typed explicitly typed extensional equality intensional equality predicative * impredicative Turing-complete sub-turing complete elegant objects theory objects? processes are primitive no primitive processes proofs as proof trees proofs as proof scripts *Deep insight of Poincaré.

Why Study CTT?. A Revolution in programming is coming. Logical Programming Environments (LPEs) providing advanced formal methods including provers, like Coq, HOL, and Nuprl, are coming to industry, there will be room for many new ideas and a race to the top. Intel understood formal methods for hardware, will they get it for software? Will Microsoft or will they have the best 1970s technology?

Why Study CTT? 3. The Idea Revolution has happened, built on automated reasoning, constructive logics, correct-by-construction programming, large libraries of formal knowledge. These ideas will be manifest broadly, from mathematics and physics to biology -- with exciting breakthroughs.

Selected Notable Examples Four Color Theorem formalization Gonthier Kepler Conjecture Work Halles with HOL team and INRIA team Constructive Higman s Lemma Murthy Prime Number Theorem Harrison, Avigad Kruskal s Theorem Seisenberger Intel s verified floating point arith -- Harrison POPLMark Challenge Coq,Twelf,HOL Paris driverless Metro line 14 Abrial, B-tool Mizar s Journal of Formalized Mathematics

Selected Notable Examples Automatically Generated Correct-by- Construction Authentication Protocols Bickford Verified ML Compiler Dr. Who Other examples?

Lecture 1 Outline Brief history of type theory from 1908 to 010 Overview of Computational Type Theory (CTT) CTT Computation System terms, evaluation, Howe s squiggle (~) CTT Type System Martin-Löf s semantic method, Allen s PER model Exercises and Recommended Reading

Historical Backdrop The research that led to modern type theories was done against the backdrop of a crisis in mathematics which caused logicians to look at ways to be more rigorous and precise about basic concepts. Key players in setting the stage were: Frege Begriffsschrift Cantor Set Theory 1879 1874

Origins Russell & Whitehead Hilbert Brouwer Zermelo Church Gentzen Herbrand Kolmogorov McCarthy Kleene Kreisel Heyting de Bruijn Bishop Milner Scott Girard Martin-Löf Lisp (Algol68) ML HOL Nuprl Coq Alf ( Automath ) Mizar

Origins

Origins continued Philosophical Issues Logicism Intuitionism Formalism Russell Brouwer Hilbert

Origins continued Philosophical issues are harmonized in CTT. -- CTT is formal but very abstract -- CTT is a constructive logic, but is classically sensible and consistent -- CTT uses propositions-as-types which relates logic and mathematics at a fundamental level

Foundational Criteria What is required for a constructive theory to be an adequate foundation for computer science? 1. Proofs-as-programs works and the theory is a programming language and programming logic combined that can be well implemented.. Computational mathematics, e.g. numerical methods, computational geometry and algebra etc. is grounded in this theory.

Foundational Criteria continued 3. Can provide a semantics to any programming language. 4. All axioms and inference rules have a computational meaning, justified by propositions-as-types. 5. The theory explains and justifies the principles of computing as they unfold. 6. Reasoning can well automated well. 7. The theory can be read classically.

Reading for Lecture 1 All reading material can be found at www.nuprl.org Douglas Howe: Equality in Lazy Computation Systems, LICS 89 Stuart Allen: Non-type theoretic definition of Martin-Löf s types, LICS 87 Nax Mendler: Inductive Definition in Type Theory, PhD thesis, 1988 see Chapter 4 Robert W. Harper: Constructing Type Systems over an Operational Semantics, J. of Symbolic Computation, 14, 71-84, 199 Christoph Kreitz: Nuprl 5 Reference Manual and User s Guide, 00 www.nuprl.org/html/0cucs-nuprlmanual.pdf see Appendix A Computational type theory: Scholarpedia, 4():7618 008

Lecture Outline CTT Inference System judgements and sequents functionality semantics of sequents propositions-as-types principle Intuitionistic Propositional Calculus in CTT Intuitionistic Predicate Calculus Heyting Arithmetic (HA) Proofs as programs Exercises

Reading for Lecture All reading material is at www.nuprl.org Proofs as Programs by Joseph L. Bates and Robert L. Constable, ACM Transactions on Programming Languages and Systems, vol. 7, no. 1, pp. 53-71. Christoph Kreitz: Nuprl 5 Reference Manual and User s Guide, 00 www.nuprl.org/html/0cucs-nuprlmanual.pdf see A.3 Inference Rules Implementing Metamathematics as an Approach to Automatic Theorem Proving by Robert L. Constable and Douglas J. Howe, Formal Techniques in Artificial Intelligence: A Source Book, R.B. Banerji (ed.), pp. 45-76, Elsevier Science, North-Holland, 1990.

Lecture 3 Outline Review and answers to exercises Programming in CTT, efficient extracts Universes and Higher-Order Logic Object-oriented types subtyping, Top type, unit records records and intersection types Exercises and Recommended Reading

Reading for Lecture 3 All reading material is at www.nuprl.org Dependent Intersection: A New Way of Defining Records in Type Theory by Alexei Kopylov, Proceedings of 18th Annual IEEE Symposium on Logic in Computer Science, pp. 86-95, 003. Type Theoretical Foundations for Data Structures, Classes, and Objects by Alexei Kopylov, Cornell University Ph.D. Thesis, 004.

Lecture 4 Outline Objectives of Proofs-as-Processes Distributed Computing Model Event Structures A Logic of Events Specifying Protocols Extracting Processes from Proofs General Process Model

Reading for Lecture 4 All reading material is located at www.nuprl.org Formal Foundations of Computer Security by Mark Bickford and Robert Constable, NATO Science for Peace and Security Series, D: Information and Communication Security, Vol. 14, pages 9-5, 008., 008. Unguessable Atoms: A Logical Foundation for Security by Mark Bickford, Verified Software: Theories, Tools, Experiments, Second International Conference, VSTTE 008 Toronto, Canada, pp 30-53, 008.

Lecture Slides Integer square root example

Integer Square Root 6 5 4 3 1 1 3 4 5 6 7 8 9 10 11 1 13 14 15 16

BY allr n: Proof of Root Theorem n :. r :. r n r r :. r n r BY NatInd 1... induction case... 1 r :. r 0 r BY existsr 0 THEN Auto... induction case... i + :, r :, r i 1 r 1 r :. r i r BY Decide r 1 1 1 1 i THEN Auto

Proof of Root Theorem (cont.)... Case 1... + i :, r :, r i 1 r 1, r 1 i r :. r i r BY existsr r 1 THEN Auto'... Case... + 1 i :, r :, r i 1 r 1, r 1 i r :. r i r BY existsr r THEN 1 Auto

The Root Program Extract Here is the extract term for this proof in ML notation with proof terms (pf) included: let rec if i sqrt i 0 then 0, pf else let in if r else 0 r, pf sqrt i - i 1 1 n then r 1, pf r, pf ' i 1 i

A Recursive Program for Integer Roots Here is a very clean functional program r(n):= if n= 0 then 0 else if fi let r 0 r (n-1) in (r 1) n then r 1 0 0 else r 0 fi This program is close to a declarative mathematical description of roots given by the following theorem.

Efficient Root Program The interactive code and the recursive program are both very inefficient. It is easy to make them efficient. root(n) : if n=0 then 0 else let r 0 = root (n/4) in if ( r 0+1) n then r 0+1 else r0 fi fi since if n 0, n/4 n This is an efficient recursive function, but why is it correct? 30

A Theorem that Roots Exist (Can be Found) Theorem Pf by Base note n:. r:. Root (r,n) efficient induction Induction Choose n = 0 let r = 0 case assume r:.root (r, n/4) r where r n/4 < (r + 1) 0 0 0 4 r n < 4 (r 1) 4 r 8 r 4 0 0 0 0 thus r root (n) < (r +1) if 0 0 ( r 0 +1) n then r = r + 1 since ( r ) = 4 r 8 r 4 else 0 0 0 r = r since ( r 0) n < ( r 0+1) Qed 31

Correctness of the Recursive Program Using this efficient induction principle. We can give a nice proof of the principle by ordinary induction. P(0) & n:.(p(n/4) P(n)) n:.p(n) 3