Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter...
Transcript of Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter...
![Page 1: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/1.jpg)
CSE 505: Programming Languages
Lecture 15 — The Curry-Howard Isomorphism
Zach TatlockWinter 2015
![Page 2: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/2.jpg)
We are Language Designers!
What have we done?I Define a programming language
I we were fairly formalI still pretty close to OCaml if you squint real hard
I Define a type systemI outlaw bad programs that “get stuck”I sound: no typable programs get stuckI incomplete: knocked out some OK programs too, ohwell
Zach Tatlock CSE 505 Winter 2015, Lecture 15 2
![Page 3: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/3.jpg)
We are Language Designers!
What have we done?I Define a programming language
I we were fairly formalI still pretty close to OCaml if you squint real hard
I Define a type systemI outlaw bad programs that “get stuck”I sound: no typable programs get stuckI incomplete: knocked out some OK programs too, ohwell
Zach Tatlock CSE 505 Winter 2015, Lecture 15 2
![Page 4: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/4.jpg)
Elsewhere in the Universe (or the other side of campus)
What do logicians do?I Define formal logics
I tools to precisely state propositions
I Define proof systemsI tools to figure out which propositions are true
Turns out, we did that too!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 3
![Page 5: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/5.jpg)
Elsewhere in the Universe (or the other side of campus)
What do logicians do?I Define formal logics
I tools to precisely state propositions
I Define proof systemsI tools to figure out which propositions are true
Turns out, we did that too!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 3
![Page 6: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/6.jpg)
Elsewhere in the Universe (or the other side of campus)
What do logicians do?I Define formal logics
I tools to precisely state propositions
I Define proof systemsI tools to figure out which propositions are true
Turns out, we did that too!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 3
![Page 7: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/7.jpg)
Punchline
We are accidental logicians!
The Curry-Howard Isomorphism
I Proofs : Propositions :: Programs : Types
I proofs are to propositions as programs are to types
Zach Tatlock CSE 505 Winter 2015, Lecture 15 4
![Page 8: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/8.jpg)
Punchline
We are accidental logicians!
The Curry-Howard Isomorphism
I Proofs : Propositions :: Programs : Types
I proofs are to propositions as programs are to types
Zach Tatlock CSE 505 Winter 2015, Lecture 15 4
![Page 9: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/9.jpg)
Woah. Back up a second. Logic?!
Let’s trim down our (explicitly typed) simply-typed λ-calculus to:
e ::= x | λx. e | e e| (e, e) | e.1 | e.2| A(e) | B(e) | match e with Ax. e | Bx. e
τ ::= b | τ → τ | τ ∗ τ | τ + τ
I Lambdas, Pairs, and Sums
I Any number of base types b1, b2, . . .
I No constants (can add one or more if you want)
I No fix
What good is this?!
Well, even sans constants, plenty of terms type-check with Γ = ·
Zach Tatlock CSE 505 Winter 2015, Lecture 15 5
![Page 10: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/10.jpg)
Woah. Back up a second. Logic?!
Let’s trim down our (explicitly typed) simply-typed λ-calculus to:
e ::= x | λx. e | e e| (e, e) | e.1 | e.2| A(e) | B(e) | match e with Ax. e | Bx. e
τ ::= b | τ → τ | τ ∗ τ | τ + τ
I Lambdas, Pairs, and Sums
I Any number of base types b1, b2, . . .
I No constants (can add one or more if you want)
I No fix
What good is this?!
Well, even sans constants, plenty of terms type-check with Γ = ·
Zach Tatlock CSE 505 Winter 2015, Lecture 15 5
![Page 11: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/11.jpg)
Woah. Back up a second. Logic?!
Let’s trim down our (explicitly typed) simply-typed λ-calculus to:
e ::= x | λx. e | e e| (e, e) | e.1 | e.2| A(e) | B(e) | match e with Ax. e | Bx. e
τ ::= b | τ → τ | τ ∗ τ | τ + τ
I Lambdas, Pairs, and Sums
I Any number of base types b1, b2, . . .
I No constants (can add one or more if you want)
I No fix
What good is this?!
Well, even sans constants, plenty of terms type-check with Γ = ·
Zach Tatlock CSE 505 Winter 2015, Lecture 15 5
![Page 12: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/12.jpg)
λx:b. x
has type
b→ b
Zach Tatlock CSE 505 Winter 2015, Lecture 15 6
![Page 13: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/13.jpg)
λx:b. x
has type
b→ b
Zach Tatlock CSE 505 Winter 2015, Lecture 15 6
![Page 14: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/14.jpg)
λx:b1. λf :b1 → b2. f x
has type
b1 → (b1 → b2)→ b2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 7
![Page 15: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/15.jpg)
λx:b1. λf :b1 → b2. f x
has type
b1 → (b1 → b2)→ b2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 7
![Page 16: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/16.jpg)
λx:b1 → b2 → b3. λy:b2. λz:b1. x z y
has type
(b1 → b2 → b3)→ b2 → b1 → b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 8
![Page 17: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/17.jpg)
λx:b1 → b2 → b3. λy:b2. λz:b1. x z y
has type
(b1 → b2 → b3)→ b2 → b1 → b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 8
![Page 18: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/18.jpg)
λx:b1. (A(x),A(x))
has type
b1 → ((b1 + b7) ∗ (b1 + b4))
Zach Tatlock CSE 505 Winter 2015, Lecture 15 9
![Page 19: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/19.jpg)
λx:b1. (A(x),A(x))
has type
b1 → ((b1 + b7) ∗ (b1 + b4))
Zach Tatlock CSE 505 Winter 2015, Lecture 15 9
![Page 20: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/20.jpg)
λf :b1 → b3. λg:b2 → b3. λz:b1 + b2.(match z with Ax. f x | Bx. g x)
has type
(b1 → b3)→ (b2 → b3)→ (b1 + b2)→ b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 10
![Page 21: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/21.jpg)
λf :b1 → b3. λg:b2 → b3. λz:b1 + b2.(match z with Ax. f x | Bx. g x)
has type
(b1 → b3)→ (b2 → b3)→ (b1 + b2)→ b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 10
![Page 22: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/22.jpg)
λx:b1 ∗ b2. λy:b3. ((y, x.1), x.2)
has type
(b1 ∗ b2)→ b3 → ((b3 ∗ b1) ∗ b2)
Zach Tatlock CSE 505 Winter 2015, Lecture 15 11
![Page 23: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/23.jpg)
λx:b1 ∗ b2. λy:b3. ((y, x.1), x.2)
has type
(b1 ∗ b2)→ b3 → ((b3 ∗ b1) ∗ b2)
Zach Tatlock CSE 505 Winter 2015, Lecture 15 11
![Page 24: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/24.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 25: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/25.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 26: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/26.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 27: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/27.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 28: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/28.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 29: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/29.jpg)
Empty and Nonempty Types
Just saw a few “nonempty” types
I τ nonempy if closed term e has type τ
I τ empty otherwise
Are there any empty types?
Sure! b1 b1 → b2 b1 → (b2 → b1)→ b2
What does this one mean?
b1 + (b1 → b2)
I wonder if there’s any way to distinguish empty vs. nonempty...
Ohwell, now for a totally irrelevant tangent!
Zach Tatlock CSE 505 Winter 2015, Lecture 15 12
![Page 30: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/30.jpg)
Totally irrelevant tangent.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 13
![Page 31: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/31.jpg)
Propositional Logic
Suppose we have some set b of basic propositions b1, b2, . . .
I e.g. “ML is better than Haskell”
Then, using standard operators ⊃,∧,∨, we can define formulas:
p ::= b | p ⊃ p | p ∧ p | p ∨ pI e.g. “ML is better than Haskell” ∧ “Haskell is not pure”
Some formulas are tautologies: by virtue of their structure, theyare always true regardless of the truth of their constituentpropositions.
I e.g. p1 ⊃ p1
Not too hard to build a proof system to establish tautologyhood.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 14
![Page 32: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/32.jpg)
Propositional Logic
Suppose we have some set b of basic propositions b1, b2, . . .
I e.g. “ML is better than Haskell”
Then, using standard operators ⊃,∧,∨, we can define formulas:
p ::= b | p ⊃ p | p ∧ p | p ∨ pI e.g. “ML is better than Haskell” ∧ “Haskell is not pure”
Some formulas are tautologies: by virtue of their structure, theyare always true regardless of the truth of their constituentpropositions.
I e.g. p1 ⊃ p1
Not too hard to build a proof system to establish tautologyhood.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 14
![Page 33: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/33.jpg)
Propositional Logic
Suppose we have some set b of basic propositions b1, b2, . . .
I e.g. “ML is better than Haskell”
Then, using standard operators ⊃,∧,∨, we can define formulas:
p ::= b | p ⊃ p | p ∧ p | p ∨ pI e.g. “ML is better than Haskell” ∧ “Haskell is not pure”
Some formulas are tautologies: by virtue of their structure, theyare always true regardless of the truth of their constituentpropositions.
I e.g. p1 ⊃ p1
Not too hard to build a proof system to establish tautologyhood.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 14
![Page 34: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/34.jpg)
Propositional Logic
Suppose we have some set b of basic propositions b1, b2, . . .
I e.g. “ML is better than Haskell”
Then, using standard operators ⊃,∧,∨, we can define formulas:
p ::= b | p ⊃ p | p ∧ p | p ∨ pI e.g. “ML is better than Haskell” ∧ “Haskell is not pure”
Some formulas are tautologies: by virtue of their structure, theyare always true regardless of the truth of their constituentpropositions.
I e.g. p1 ⊃ p1
Not too hard to build a proof system to establish tautologyhood.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 14
![Page 35: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/35.jpg)
Propositional Logic
Suppose we have some set b of basic propositions b1, b2, . . .
I e.g. “ML is better than Haskell”
Then, using standard operators ⊃,∧,∨, we can define formulas:
p ::= b | p ⊃ p | p ∧ p | p ∨ pI e.g. “ML is better than Haskell” ∧ “Haskell is not pure”
Some formulas are tautologies: by virtue of their structure, theyare always true regardless of the truth of their constituentpropositions.
I e.g. p1 ⊃ p1
Not too hard to build a proof system to establish tautologyhood.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 14
![Page 36: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/36.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 37: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/37.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 38: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/38.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 39: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/39.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 40: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/40.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 41: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/41.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 42: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/42.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 43: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/43.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` p
Γ, p1 ` p2Γ ` p1 ⊃ p2
Γ ` p1 ⊃ p2 Γ ` p1Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 44: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/44.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2
Γ ` p1 ⊃ p2 Γ ` p1Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 45: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/45.jpg)
Proof System
Γ ::= · | Γ, p
Γ ` p
Γ ` p1 Γ ` p2Γ ` p1 ∧ p2
Γ ` p1 ∧ p2Γ ` p1
Γ ` p1 ∧ p2Γ ` p2
Γ ` p1Γ ` p1 ∨ p2
Γ ` p2Γ ` p1 ∨ p2
Γ ` p1 ∨ p2 Γ, p1 ` p3 Γ, p2 ` p3Γ ` p3
p ∈ Γ
Γ ` pΓ, p1 ` p2
Γ ` p1 ⊃ p2Γ ` p1 ⊃ p2 Γ ` p1
Γ ` p2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 15
![Page 46: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/46.jpg)
Wait a second...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 16
![Page 47: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/47.jpg)
Wait a second...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 16
![Page 48: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/48.jpg)
Wait a second... ZOMG!
That’s exactly our type system! Just erase terms, change each τ to a p,and translate→ to ⊃, ∗ to ∧, + to ∨.
Γ ` e : τ
Γ ` e1 : τ1 Γ ` e2 : τ2
Γ ` (e1, e2) : τ1 ∗ τ2Γ ` e : τ1 ∗ τ2Γ ` e.1 : τ1
Γ ` e : τ1 ∗ τ2Γ ` e.2 : τ2
Γ ` e : τ1
Γ ` A(e) : τ1 + τ2
Γ ` e : τ2
Γ ` B(e) : τ1 + τ2
Γ ` e : τ1 + τ2 Γ, x:τ1 ` e1 : τ Γ, y:τ2 ` e2 : τ
Γ ` match e with Ax. e1 | By. e2 : τ
Γ(x) = τ
Γ ` x : τ
Γ, x : τ1 ` e : τ2
Γ ` λx. e : τ1 → τ2
Γ ` e1 : τ2 → τ1 Γ ` e2 : τ2
Γ ` e1 e2 : τ1
Zach Tatlock CSE 505 Winter 2015, Lecture 15 17
![Page 49: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/49.jpg)
What does it all mean? The Curry-Howard Isomorphism.
I Given a well-typed closed term, take the typing derivation,erase the terms, and have a propositional-logic proof
I Given a propositional-logic proof, there exists a closed termwith that type
I A term that type-checks is a proof — it tells you exactly howto derive the logic formula corresponding to its type
I Constructive (hold that thought) propositional logic andsimply-typed lambda-calculus with pairs and sums are thesame thing.
I Computation and logic are deeply connectedI λ is no more or less made up than implication
I Revisit our examples under the logical interpretation...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 18
![Page 50: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/50.jpg)
What does it all mean? The Curry-Howard Isomorphism.
I Given a well-typed closed term, take the typing derivation,erase the terms, and have a propositional-logic proof
I Given a propositional-logic proof, there exists a closed termwith that type
I A term that type-checks is a proof — it tells you exactly howto derive the logic formula corresponding to its type
I Constructive (hold that thought) propositional logic andsimply-typed lambda-calculus with pairs and sums are thesame thing.
I Computation and logic are deeply connectedI λ is no more or less made up than implication
I Revisit our examples under the logical interpretation...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 18
![Page 51: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/51.jpg)
λx:b. x
is a proof that
b→ b
Zach Tatlock CSE 505 Winter 2015, Lecture 15 19
![Page 52: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/52.jpg)
λx:b1. λf :b1 → b2. f x
is a proof that
b1 → (b1 → b2)→ b2
Zach Tatlock CSE 505 Winter 2015, Lecture 15 20
![Page 53: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/53.jpg)
λx:b1 → b2 → b3. λy:b2. λz:b1. x z y
is a proof that
(b1 → b2 → b3)→ b2 → b1 → b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 21
![Page 54: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/54.jpg)
λx:b1. (A(x),A(x))
is a proof that
b1 → ((b1 + b7) ∗ (b1 + b4))
Zach Tatlock CSE 505 Winter 2015, Lecture 15 22
![Page 55: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/55.jpg)
λf :b1 → b3. λg:b2 → b3. λz:b1 + b2.(match z with Ax. f x | Bx. g x)
is a proof that
(b1 → b3)→ (b2 → b3)→ (b1 + b2)→ b3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 23
![Page 56: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/56.jpg)
λx:b1 ∗ b2. λy:b3. ((y, x.1), x.2)
is a proof that
(b1 ∗ b2)→ b3 → ((b3 ∗ b1) ∗ b2)
Zach Tatlock CSE 505 Winter 2015, Lecture 15 24
![Page 57: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/57.jpg)
So what?
Because:
I This is just fascinating (glad I’m not a dog)
I Don’t think of logic and computing as distinct fields
I Thinking “the other way” can help you know what’spossible/impossible
I Can form the basis for theorem provers
I Type systems should not be ad hoc piles of rules!
So, every typed λ-calculus is a proof system for some logic...
Is STLC with pairs and sums a complete proof system forpropositional logic? Almost...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 25
![Page 58: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/58.jpg)
So what?
Because:
I This is just fascinating (glad I’m not a dog)
I Don’t think of logic and computing as distinct fields
I Thinking “the other way” can help you know what’spossible/impossible
I Can form the basis for theorem provers
I Type systems should not be ad hoc piles of rules!
So, every typed λ-calculus is a proof system for some logic...
Is STLC with pairs and sums a complete proof system forpropositional logic? Almost...
Zach Tatlock CSE 505 Winter 2015, Lecture 15 25
![Page 59: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/59.jpg)
Classical vs. Constructive
Classical propositional logic has the “law of the excluded middle”:
Γ ` p1 + (p1 → p2)
(Think “p+¬p” – also equivalent to double-negation ¬¬p→ p)
STLC does not support this law; for example, no closed expressionhas type b1 + (b1 → b2)
Logics without this rule are called constructive. They’re usefulbecause proofs “know how the world is” and “are executable” and“produce examples”
Can still “branch on possibilities” by making the excluded middlean explicit assumption:
((p1 + (p1 → p2)) ∗ (p1 → p3) ∗ ((p1 → p2)→ p3))→ p3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 26
![Page 60: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/60.jpg)
Classical vs. Constructive
Classical propositional logic has the “law of the excluded middle”:
Γ ` p1 + (p1 → p2)
(Think “p+¬p” – also equivalent to double-negation ¬¬p→ p)
STLC does not support this law; for example, no closed expressionhas type b1 + (b1 → b2)
Logics without this rule are called constructive. They’re usefulbecause proofs “know how the world is” and “are executable” and“produce examples”
Can still “branch on possibilities” by making the excluded middlean explicit assumption:
((p1 + (p1 → p2)) ∗ (p1 → p3) ∗ ((p1 → p2)→ p3))→ p3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 26
![Page 61: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/61.jpg)
Classical vs. Constructive
Classical propositional logic has the “law of the excluded middle”:
Γ ` p1 + (p1 → p2)
(Think “p+¬p” – also equivalent to double-negation ¬¬p→ p)
STLC does not support this law; for example, no closed expressionhas type b1 + (b1 → b2)
Logics without this rule are called constructive. They’re usefulbecause proofs “know how the world is” and “are executable” and“produce examples”
Can still “branch on possibilities” by making the excluded middlean explicit assumption:
((p1 + (p1 → p2)) ∗ (p1 → p3) ∗ ((p1 → p2)→ p3))→ p3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 26
![Page 62: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/62.jpg)
Classical vs. Constructive
Classical propositional logic has the “law of the excluded middle”:
Γ ` p1 + (p1 → p2)
(Think “p+¬p” – also equivalent to double-negation ¬¬p→ p)
STLC does not support this law; for example, no closed expressionhas type b1 + (b1 → b2)
Logics without this rule are called constructive. They’re usefulbecause proofs “know how the world is” and “are executable” and“produce examples”
Can still “branch on possibilities” by making the excluded middlean explicit assumption:
((p1 + (p1 → p2)) ∗ (p1 → p3) ∗ ((p1 → p2)→ p3))→ p3
Zach Tatlock CSE 505 Winter 2015, Lecture 15 26
![Page 63: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/63.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones? LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 64: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/64.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones? LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 65: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/65.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones?
LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 66: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/66.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones? LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 67: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/67.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones? LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 68: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/68.jpg)
Classical vs. Constructive, an Example
Theorem: There exist irrational numbers a and b such that ab is rational.
Classical Proof:
Let x =√
2. Either xx is rational or it is irrational.
If xx is rational, let a = b =√
2, done.
If xx is irrational, let a = xx and b = x. Since(√2
√2)√2
=√
2(√
2·√
2)=√
22
= 2, done.
Well, I guess we know there are some a and b satisfying the theorem...but which ones? LAME.
Constructive Proof:
Let a =√
2, b = log2 9.
Since√
2log2 9
= 9log2
√2 = 9log2(2
0.5) = 90.5 = 3, done.
To prove that something exists, we actually had to produce it. SWEET.Zach Tatlock CSE 505 Winter 2015, Lecture 15 27
![Page 69: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/69.jpg)
Classical vs. Constructive, a Perspective
Constructive logic allows us to distinguish between things thatclassical logic lumps together.
Consider “P is true.” vs. “It would be absurd if P were false.”I P vs. ¬¬P
Those are different things, but classical logic can’t tell.
Our friends Godel and Gentzen gave us thisnice result:
P is provable in classical logic iff ¬¬P isprovable in constructive logic.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 28
![Page 70: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/70.jpg)
Classical vs. Constructive, a Perspective
Constructive logic allows us to distinguish between things thatclassical logic lumps together.
Consider “P is true.” vs. “It would be absurd if P were false.”I P vs. ¬¬P
Those are different things, but classical logic can’t tell.
Our friends Godel and Gentzen gave us thisnice result:
P is provable in classical logic iff ¬¬P isprovable in constructive logic.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 28
![Page 71: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/71.jpg)
Classical vs. Constructive, a Perspective
Constructive logic allows us to distinguish between things thatclassical logic lumps together.
Consider “P is true.” vs. “It would be absurd if P were false.”I P vs. ¬¬P
Those are different things, but classical logic can’t tell.
Our friends Godel and Gentzen gave us thisnice result:
P is provable in classical logic iff ¬¬P isprovable in constructive logic.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 28
![Page 72: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/72.jpg)
Classical vs. Constructive, a Perspective
Constructive logic allows us to distinguish between things thatclassical logic lumps together.
Consider “P is true.” vs. “It would be absurd if P were false.”I P vs. ¬¬P
Those are different things, but classical logic can’t tell.
Our friends Godel and Gentzen gave us thisnice result:
P is provable in classical logic iff ¬¬P isprovable in constructive logic.
Zach Tatlock CSE 505 Winter 2015, Lecture 15 28
![Page 73: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/73.jpg)
Fix
A “non-terminating proof” is no proof at all.
Remember the typing rule for fix:
Γ ` e : τ → τ
Γ ` fix e : τ
That let’s us prove anything! Example: fix λx:b. x has type b
So the “logic” is inconsistent (and therefore worthless)
Related: In ML, a value of type ’a never terminates normally(raises an exception, infinite loop, etc.)
let rec f x = f x
let z = f 0
Zach Tatlock CSE 505 Winter 2015, Lecture 15 29
![Page 74: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/74.jpg)
Last word on Curry-Howard
It’s not just STLC and constructive propositional logic
Every logic has a correspondng typed λ calculus (and no consistentlogic has something as “powerful” as fix).
I Example: When we add universal types (“generics”) in a laterlecture, that corresponds to adding universal quantification
If you remember one thing: the typing rule for function applicationis modus ponens
Zach Tatlock CSE 505 Winter 2015, Lecture 15 30
![Page 75: Lecture 15 The Curry-Howard IsomorphismLecture 15 | The Curry-Howard Isomorphism Zach Tatlock Winter 2015. We are Language Designers! What have we done? I De ne a programming language](https://reader035.fdocuments.in/reader035/viewer/2022071419/611726231a7dff71aa2cd36c/html5/thumbnails/75.jpg)
Last word on Curry-Howard
It’s not just STLC and constructive propositional logic
Every logic has a correspondng typed λ calculus (and no consistentlogic has something as “powerful” as fix).
I Example: When we add universal types (“generics”) in a laterlecture, that corresponds to adding universal quantification
If you remember one thing: the typing rule for function applicationis modus ponens
Zach Tatlock CSE 505 Winter 2015, Lecture 15 30