Top Banner
Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)
35

Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

Proofs are Programs:19th Century Logic

and21st Century Computing

CS 510: Programming Languages(a talk adapted from Philip Wadler)

Page 2: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

How to Talk to Aliens

Page 3: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

Basic natural phenomena

• Some mathematical phenomena seem so unavoidable that we must view them as “discovered” rather than “invented”– natural numbers

• 0 appears first in India (700 CE)

– mathematical constants• pi, e

– geometry• basic shapes (circle, triangle)• geometric laws (triangle inequality, area and volume)

Page 4: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

Computer Science

• Invented or discovered?

• Are there fundamental, unavoidable computational phenomena?– laws or concepts with the same unavoidable feeling

as Newton’s laws of gravity?

• How would we know?– these concepts would appear across time and culture– but computer science is only 50 years old! Or is it?

Page 5: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

The History of Logic

• George Boole– 1815-1864– inventor (discoverer?) of

Boolean algebra– conjectured the existence of

fundamental Laws of Thought

Page 6: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

The History of Logic

• George Boole (Laws of Thought, 1854)

Page 7: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gotlob Frege (1848-1925)– the first hints of modern logic– formal diagrams to depict

mathematical inferences

Page 8: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Frege’s inferences (1879)

• Look vaguely familiar?

Page 9: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Frege continued (1879)

Page 10: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Frege in modern notation

Page 11: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gerhard Gentzen (1934)– Natural Deduction– The definition of logical

connectives exclusively in terms of introduction of the connective and elimination of the connective

– Prior work specified logic via axioms that related one connective to another

Page 12: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gentzen (1934)

Page 13: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gentzen (1934)

Page 14: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gentzen (1934)– in modern notation:

Page 15: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Gentzen (1934)– proof simplification rules:

Page 16: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Proof simplification

Page 17: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Proof simplification

Page 18: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Alonzo Church– invented (discovered?) the

lambda calculus– the first programming

language researcher

Page 19: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Alonzo Church (1903-1995)– invented (discovered?) the

lambda calculus– the first programming

language researcher– he didn’t know it at the time

(we were still lacking the computers)

Page 20: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Church (1932)– the introduction of free and bound variables

Page 21: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Church (1932)

– the logic is defined entirely and abstractly by a system of inference rules

– symbols do not have pre-conceived meanings– pure logic uninfluenced by culture

Page 22: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Church (1932)

– in case you missed the last line

– I’ll say.

Page 23: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Church (1932)– proof terms, bound variables and the notion of

well-formed objects

Page 24: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Computing with Church’s lambda calculus

• General evaluation rules:

Page 25: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Sample evaluation

Page 26: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Church’s typed lambda calculus

Page 27: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Simplifying programs

Page 28: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Simplifying programs

Page 29: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Curry-Howard Isomorphism

Haskell Curry (1900-1982) William Howard

Page 30: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Curry-Howard Isomorphism

– First noticed by Curry in 1960

– First published by Howard in 1980

• Fundamental ideas:– Proofs are programs

– Formulas are types

– Proof rules are type checking rules

– Proof simplification is operational semantics

– Ideas and observations about logic are ideas and observations about programming languages

Page 31: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic• Curry-Howard (intuitionistic logic)

2nd-order intuitionistic logic

(formula variable) a(implication) A => B(conjunction) A B(disjunction) A B(truth) True(falsehood) False(universal quant) a.A(existential quant) a.A

Polymorphic Lambda Calculus(PolyMinML - recursion)

(type variable) a(function type) A B(pair type) A * B(sum type) A + B(unit) unit(void) void(universal poly) a.A(existential poly) a.A

Page 32: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Curry-Howard (intuitionistic logic)

• Note: You don’t have to omit proof terms from logical rules

2nd-order intuitionistic logic Polymorphic Lambda Calculus

G |- A => B G |- A------------------------------- (=>E)G |- B

G, x:A |- e : B --------------------------(Fun)G |- x:A.e : A => B

G, A |- B -------------------------- (=> I)G |- A => B

G |- e1 : A => B G |- e2 : A---------------------------------- (App)G |- e1 e2 : B

Page 33: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Curry-Howard (intuitionistic logic)

2nd-order intuitionistic logic Polymorphic Lambda Calculus

G |- A B ------------- (E1)G |- A

G |- e1 : A G |- e2 : B ------------------------------(Pair)G |- <e1,e2> : A * B

G |- A G |- B ------------------- ( I)G |- A B

G |- A B ------------- (E2)G |- B

G |- e : A B ----------------- (E1)G |- e.1 : A

G |- e : A B ----------------- (E2)G |- e.2 B

Page 34: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• Other Examples– Hindley/Milner: formula reconstruction/type inference– Girard/Reynolds:

• System F/Polymorphic lambda calculus

• Linear Logic/Syntactic control of interference, linear types

– Murthy: classical logic/callcc – Abramsky: multiplicative vs additive/strict vs lazy– Pfenning and Davies: modal logic/RTCG– Phil Wadler: and dual to or/CBV dual to CBN

Page 35: Proofs are Programs: 19th Century Logic and 21st Century Computing CS 510: Programming Languages (a talk adapted from Philip Wadler)

History of Logic

• The Curry-Howard isomorphism– Coincidence? Or are aliens trying to tell us something?

– Identical concepts arise across time and culture

– Certain logical/computational definitions seem unavoidable

– Are they inventions or discoveries?

• Is this talk about the history of logic or the history of computer programming?

• Was this course about logic or computer science?