An OCaml-based automated theorem-proving textbook

Similar documents
AXIOMS FOR THE INTEGERS

CS3110 Spring 2017 Lecture 10 a Module for Rational Numbers

CS457/557 Functional Languages

INTRODUCTION TO MATHEMATICAL PROOFS: A TRANSITION (TEXTBOOKS IN MATHEMATICS) BY CHARLES ROBERTS

CS 11 Haskell track: lecture 1

First Order Logic in Practice 1 First Order Logic in Practice John Harrison University of Cambridge Background: int

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Chapter 2 The Language PCF

CS 242. Fundamentals. Reading: See last slide

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Lecture 3: Linear Classification

Packaging Theories of Higher Order Logic

Programming Languages Third Edition

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

CIS 500 Software Foundations Fall September 25

What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora

Introduction. chapter Functions

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

G Programming Languages - Fall 2012

Turning proof assistants into programming assistants

Lecture Notes on Data Representation

In Our Last Exciting Episode

Appendix G: Some questions concerning the representation of theorems

3.1 Constructions with sets

Types and Static Type Checking (Introducing Micro-Haskell)

CS153: Compilers Lecture 1: Introduction

Embedding Cryptol in Higher Order Logic

How Efficient Can Fully Verified Functional Programs Be - A Case Study of Graph Traversal Algorithms

Introduction. Chapter The Nuprl 5 Architecture

CS 4349 Lecture August 21st, 2017

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

An LCF-Style Interface between HOL and First-Order Logic

1

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

First Order Logic in Practice

Notes on CSP. Will Guaraldi, et al. version 1.7 4/18/2007

Modeling Programming Languages Formally

A Theory of Parallel Computation The π-calculus

Formal Verification in Industry

A.1 Numbers, Sets and Arithmetic

CMSC 330: Organization of Programming Languages. Functional Programming with OCaml

CHAPTER ONE OVERVIEW. 1.1 Continuation-passing style

Sets. Sets. Examples. 5 2 {2, 3, 5} 2, 3 2 {2, 3, 5} 1 /2 {2, 3, 5}

Mathematical Modeling to Formally Prove Correctness

Types and Static Type Checking (Introducing Micro-Haskell)

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Isabelle/HOL:Selected Features and Recent Improvements

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

LECTURE 16. Functional Programming

NP-Complete Problems

Applied Theorem Proving: Modelling Instruction Sets and Decompiling Machine Code. Anthony Fox University of Cambridge, Computer Laboratory

CS 6110 S14 Lecture 1 Introduction 24 January 2014

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

DEGENERACY AND THE FUNDAMENTAL THEOREM

Handout 9: Imperative Programs and State

An aside. Lecture 14: Last time

In math, the rate of change is called the slope and is often described by the ratio rise

2. Use elementary row operations to rewrite the augmented matrix in a simpler form (i.e., one whose solutions are easy to find).

LECTURE 13, THURSDAY APRIL 1, 2004

Reasoning About Programs Panagiotis Manolios

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Lagrange Multipliers and Problem Formulation

Reading 1 : Introduction

First-Order Proof Tactics in Higher Order Logic Theorem Provers Joe Hurd p.1/24

4.3 Rational Thinking

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

Assistant for Language Theory. SASyLF: An Educational Proof. Corporation. Microsoft. Key Shin. Workshop on Mechanizing Metatheory

COMP12111 Fundamentals of Computer Engineering Paul Nutter Vasilis Pavlidis Comments

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Formal verification of floating-point arithmetic at Intel

(Refer Slide Time 3:31)

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

The Lambda Calculus. 27 September. Fall Software Foundations CIS 500. The lambda-calculus. Announcements

Leslie Lamport: The Specification Language TLA +

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

The design of a programming language for provably correct programs: success and failure

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Material from Recitation 1

Algorithms and Data Structures, or

Topology and Topological Spaces

RAISE in Perspective

Lecture 3: Recursion; Structural Induction

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

(1) Modular arithmetic

What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010

Formal Verification Methods 2: Symbolic Simulation

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial

Topic C. Communicating the Precision of Measured Numbers

Languages and Automata

Type Systems Winter Semester 2006

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214

Projective geometry and the extended Euclidean plane

3.7 Denotational Semantics

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

Finite Fields can be represented in various ways. Generally, they are most

Semantics of programming languages

Math Introduction to Advanced Mathematics

Transcription:

0 An OCaml-based automated theorem-proving textbook John Harrison, Intel Corporation Portland Functional Programming Study Group Mon 11th May 2009 (19:00)

1 Book plug Surveys many parts of automated reasoning, via actual code. Available online from the usual places. Hopefully will be in Powells in a couple of weeks...

2 Why I wrote this book Standard existing books on automated theorem proving mostly fall into one of these categories: Chang and Lee, Symbolic Logic and Mechanical Theorem Proving. Excellent textbook, but mainly focused on resolution with nothing on arithmetic decision procedures, and somewhat dated.

3 Why I wrote this book Standard existing books on automated theorem proving mostly fall into one of these categories: Chang and Lee, Symbolic Logic and Mechanical Theorem Proving. Excellent textbook, but mainly focused on resolution with nothing on arithmetic decision procedures, and somewhat dated. Gordon and Melham, Introduction to HOL: a theorem proving environment for higher order logic. Fine description and manual for usage of HOL system, but entirely focused on that one system and with little explanation of how it works.

4 Why I wrote this book Standard existing books on automated theorem proving mostly fall into one of these categories: Chang and Lee, Symbolic Logic and Mechanical Theorem Proving. Excellent textbook, but mainly focused on resolution with nothing on arithmetic decision procedures, and somewhat dated. Gordon and Melham, Introduction to HOL: a theorem proving environment for higher order logic. Fine description and manual for usage of HOL system, but entirely focused on that one system and with little explanation of how it works. There are essentially no textbooks on automated theorem proving covering a wide range of the subject without many prerequisites.

5 Approach of my book In principle, assumes almost no prerequisites, but discusses logic from the very beginning. Does require basic mathematics and functional programming (but these are summarized in appendices).

6 Approach of my book In principle, assumes almost no prerequisites, but discusses logic from the very beginning. Does require basic mathematics and functional programming (but these are summarized in appendices). Logical theory and automated theorem proving are explained in a closely intertwined manner. Results in logic are developed, wherever possible, in an explicitly computational way.

7 Approach of my book In principle, assumes almost no prerequisites, but discusses logic from the very beginning. Does require basic mathematics and functional programming (but these are summarized in appendices). Logical theory and automated theorem proving are explained in a closely intertwined manner. Results in logic are developed, wherever possible, in an explicitly computational way. Methods are explained with reference to actual concrete implementations in OCaml, which readers can experiment with if they have convenient access to a computer.

8 Nice Knuth quote... For three years I taught a sophomore course in abstract algebra for mathematics majors at Caltech, and the most difficult topic was always the study of Jordan canonical forms for matrices. The third year I tried a new approach, by looking at the subject algorithmically, and suddenly it became quite clear. The same thing happened with the discussion of finite groups defined by generators and relations, and in another course with the reduction theory of binary quadratic forms. By presenting the subject in terms of algorithms, the purpose and meaning of the mathematical theorems became transparent.

9... Knuth quote continued Later, while writing a book on computer arithmetic [...], I found that virtually every theorem in elementary number theory arises in a natural, motivated way in connection with the problem of making computers do high-speed numerical calculations. Therefore I believe that the traditional courses in number theory might well be changed to adopt this point of view, adding a practical motivation to the already beautiful theory.

10 More self-justification Other recent-ish mathematics books take a similar approach: Cox, Little and O Shea, Using algebraic geometry Kreuzer, Computational commutative algebra Rydeheard and Burstall, Computational category theory

11 More self-justification Other recent-ish mathematics books take a similar approach: Cox, Little and O Shea, Using algebraic geometry Kreuzer, Computational Commutative Algebra Rydeheard and Burstall, Computational category theory If even category theory can be presented computationally, surely mathematical logic deserves to be: Analysis of computation by Turing and others was specifically designed to address decidability questions in logic Problems in formal verification are motivating the development of automated theorem provers. Logic plays increasing role in programming language design.

12 Table of contents 1. Introduction 2. Propositional logic 3. First-order logic 4. Equality 5. Decidable problems 6. Interactive theorem proving 7. Limitations 8. Appendices on mathematical background and basic OCaml

13 Why in a functional language? Compare another implementation-oriented book, Monty Newborn s Automated Theorem Proving: Theory and Practice. What does a functional language give us?

14 Why in a functional language? Compare another implementation-oriented book, Monty Newborn s Automated Theorem Proving: Theory and Practice. What does a functional language give us? High level of data structures, abstraction from machine features like memory allocation: as good as pseudocode yet executable. Interactive toplevel very convenient for experimentation. Purely functional programming allows exploration without worrying about accidental side-effects.

15 Why in a functional language? Compare another implementation-oriented book, Monty Newborn s Automated Theorem Proving: Theory and Practice. What does a functional language give us? High level of data structures, abstraction from machine features like memory allocation: as good as pseudocode yet executable. Interactive toplevel very convenient for experimentation. Purely functional programming allows exploration without worrying about accidental side-effects. On the negative side: Less familiar to many readers than C, Java, pseudocode...

16 Why OCaml? I started using CAML Light when I rewrote the HOL theorem prover in it to give HOL Light. Since then I ve stayed on the upgrade path via CAML Special Light to OCaml and been quite satisfied. I don t use any exotic features like object orientation, labelled arguments etc. Except for printing status messages, all code is completely functional, in traditional ML style. I do use automatic prettyprinting and (via camlp4/camlp5) quotation parsing to make interactive exploration convenient. Only significant complaint about OCaml was the ineptly managed transition to a new, incompatible and completely undocumented version of camlp4.

17 Versions in other languages? I d love to have versions of the code in multiple functional languages. Since I use a lowest common denominator subset, this shouldn t be too bad. An F# version is almost trivial, because the core language is so close to OCaml. The only exception is parsing and printing, which would need to change. Sean McLaughlin and Roland Zumkeller have worked on a Haskell port, and have already done a significant portion. Toplevel seems less efficient, but compiled version works very well. It would be interesting to try rewriting some of the code in a more thematic Haskell style using laziness, list comprehensions etc.