a review of the curry-howard-de bruijn formulas-as-types ...herman/slidesmlnl2009.pdf · i realism:...
TRANSCRIPT
![Page 1: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/1.jpg)
A review of the Curry-Howard-De Bruijnformulas-as-types interpretation
Herman Geuvers
Foundations group, Intelligent Systems, ICISRadboud University Nijmegen
The Netherlands
Mathematical Logic in the NetherlandsMay 26,, 2009,
Radboud University Nijmegen
![Page 2: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/2.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 3: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/3.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 4: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/4.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 5: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/5.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 6: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/6.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 7: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/7.jpg)
What is mathematics about?
Foundations of mathematics:
I Formalism: mathematics is a formal game with formal rules.Meaning? Only finitary maths has a canonical meaning. Atheory is good if it is consistent. Hilbert
I Realism: But mathematics also has a relation with the realworld! Also infinitary mathematics!
I Platonism: Abstract and infinitary mathematical objects also“exist”.
I Logicism: Logics is the universal basis; build mathematics outof logics. Frege, Russell
I Intuitionism / Constructivism: Only the objects that one canconstruct (in time) exist. Brouwer
![Page 8: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/8.jpg)
Brouwer’s Intuitionism
Mathematics is primary and comes before logic. Logic isdescriptive.Basic intuition: construction of an object in time: NA proof (mathematical argument) is also a construction (in time).
What can we construct? Which mathematical arguments are valid?
Theorem: ∃p, q, irrational(pq is rational)
Proof:√
2√
2is rational OR irrational.
- First case: done; p = q =√
2
- Second case: (√
2√
2)√
2 = 2 is rational and so we are done:
p =√
2√
2, q =
√2
![Page 9: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/9.jpg)
Brouwer’s Intuitionism
Mathematics is primary and comes before logic. Logic isdescriptive.Basic intuition: construction of an object in time: NA proof (mathematical argument) is also a construction (in time).
What can we construct? Which mathematical arguments are valid?
Theorem: ∃p, q, irrational(pq is rational)
Proof:√
2√
2is rational OR irrational.
- First case: done; p = q =√
2
- Second case: (√
2√
2)√
2 = 2 is rational and so we are done:
p =√
2√
2, q =
√2
![Page 10: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/10.jpg)
The intuitionistic notion of truth
Brouwer: A statement is true if we have a proof for it.
So the real question is:
What is a proof?
Brouwer has never made this formally precise, because Brouwerwasn’t interested in logic. Heyting and Kolmogorov have.
![Page 11: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/11.jpg)
The intuitionistic notion of truth
Brouwer: A statement is true if we have a proof for it.
So the real question is:
What is a proof?
Brouwer has never made this formally precise, because Brouwerwasn’t interested in logic. Heyting and Kolmogorov have.
![Page 12: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/12.jpg)
Brouwer-Heyting-Kolmogorov interpretation (BHK)
![Page 13: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/13.jpg)
Brouwer-Heyting-Kolmogorov interpretation (BHK)
A proof ofA ∧ B is a pair consisting of a proof of A and a proof of BA ∨ B is a proof of A or a proof of BA→ B is a method for producing a proof of B,
given a proof of A⊥ doesn’t exist
∀x ∈ D(A(x)) is a method for producing a proof of A(d),given an element d ∈ D,
∃x ∈ D(A(x)) is a pair consisting of an element d ∈ Dand a proof of A(d).
So: there is no proof of A ∨ ¬ASo: a proof of ∀x ∈ D∃y ∈ E (A(x , y)) contains a method forconstructing a e ∈ E for every d ∈ D such that A(d , e) holds.
![Page 14: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/14.jpg)
Brouwer-Heyting-Kolmogorov interpretation (BHK)
A proof ofA ∧ B is a pair consisting of a proof of A and a proof of BA ∨ B is a proof of A or a proof of BA→ B is a method for producing a proof of B,
given a proof of A⊥ doesn’t exist
∀x ∈ D(A(x)) is a method for producing a proof of A(d),given an element d ∈ D,
∃x ∈ D(A(x)) is a pair consisting of an element d ∈ Dand a proof of A(d).
So: there is no proof of A ∨ ¬A
So: a proof of ∀x ∈ D∃y ∈ E (A(x , y)) contains a method forconstructing a e ∈ E for every d ∈ D such that A(d , e) holds.
![Page 15: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/15.jpg)
Brouwer-Heyting-Kolmogorov interpretation (BHK)
A proof ofA ∧ B is a pair consisting of a proof of A and a proof of BA ∨ B is a proof of A or a proof of BA→ B is a method for producing a proof of B,
given a proof of A⊥ doesn’t exist
∀x ∈ D(A(x)) is a method for producing a proof of A(d),given an element d ∈ D,
∃x ∈ D(A(x)) is a pair consisting of an element d ∈ Dand a proof of A(d).
So: there is no proof of A ∨ ¬ASo: a proof of ∀x ∈ D∃y ∈ E (A(x , y)) contains a method forconstructing a e ∈ E for every d ∈ D such that A(d , e) holds.
![Page 16: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/16.jpg)
Kleene Realisability, Curry-Howard Formules as Types
We can make the BHK interpretation formal in various ways:Kleene realisability
m r A
“m realises the formula A” (m ∈ N, seen as the code of a Turingmachine)
Curry-Howard formulas as types:
M : A
“M has type A” (M an algorithm / functional programma / dataobject)
I a formula is seen as a type (or a specification)
I a proof is seen as an algorithm (program)
![Page 17: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/17.jpg)
Kleene Realisability, Curry-Howard Formules as Types
We can make the BHK interpretation formal in various ways:Kleene realisability
m r A
“m realises the formula A” (m ∈ N, seen as the code of a Turingmachine)Curry-Howard formulas as types:
M : A
“M has type A” (M an algorithm / functional programma / dataobject)
I a formula is seen as a type (or a specification)
I a proof is seen as an algorithm (program)
![Page 18: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/18.jpg)
Formulas as Types, Proofs as Terms
A proof of (term of type)A ∧ B is a term 〈p, q〉 with p : A and q : BA ∨ B is inl p with p : A or inr q with q : BA→ B is a term f : A→ B⊥ doesn’t exist
∀x ∈ D(A(x)) is a term f : Πx∈DA(x)∃x ∈ D(A(x)) is a term 〈d , p〉 with d : D and p : A(d)
Formulas and sets are both (data)typesProofs and objects are both terms (data, programs)Two “readings” of M : A:- M is a proof of the formula A- M is data of type A
![Page 19: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/19.jpg)
Formulas as Types, Proofs as Terms
A proof of (term of type)A ∧ B is a term 〈p, q〉 with p : A and q : BA ∨ B is inl p with p : A or inr q with q : BA→ B is a term f : A→ B⊥ doesn’t exist
∀x ∈ D(A(x)) is a term f : Πx∈DA(x)∃x ∈ D(A(x)) is a term 〈d , p〉 with d : D and p : A(d)
Formulas and sets are both (data)typesProofs and objects are both terms (data, programs)
Two “readings” of M : A:- M is a proof of the formula A- M is data of type A
![Page 20: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/20.jpg)
Formulas as Types, Proofs as Terms
A proof of (term of type)A ∧ B is a term 〈p, q〉 with p : A and q : BA ∨ B is inl p with p : A or inr q with q : BA→ B is a term f : A→ B⊥ doesn’t exist
∀x ∈ D(A(x)) is a term f : Πx∈DA(x)∃x ∈ D(A(x)) is a term 〈d , p〉 with d : D and p : A(d)
Formulas and sets are both (data)typesProofs and objects are both terms (data, programs)Two “readings” of M : A:- M is a proof of the formula A- M is data of type A
![Page 21: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/21.jpg)
The Formulas-as-Types notion of Construction (Howard1980)
Paper dates back to 1969.Original ideas go back to Curry (Combinatory Logic):K := λx λy .x : A→ B → AS := λx λy λz .x z(y z) : (A→ B → C )→ (A→ B)→ A→ CI := λx .x : A→ A
Theorem: For (first order) proposition and predicate logic we havea formulas-as-types isomorphism between proofs and terms.
ϕ1, ϕ2, . . . , ϕn `ΠL σ ⇐⇒ x1 : ϕ1, x2 : ϕ2, . . . , xn : ϕn ` [Π] : σ
![Page 22: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/22.jpg)
The Formulas-as-Types notion of Construction (Howard1980)
Paper dates back to 1969.Original ideas go back to Curry (Combinatory Logic):K := λx λy .x : A→ B → AS := λx λy λz .x z(y z) : (A→ B → C )→ (A→ B)→ A→ CI := λx .x : A→ A
Theorem: For (first order) proposition and predicate logic we havea formulas-as-types isomorphism between proofs and terms.
ϕ1, ϕ2, . . . , ϕn `ΠL σ ⇐⇒ x1 : ϕ1, x2 : ϕ2, . . . , xn : ϕn ` [Π] : σ
![Page 23: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/23.jpg)
The Formulas-as-Types notion of Construction (Howard1980)
Contribution of Tait (1965):Cut-elimination in logic = β-reduction in typed λ-calculus.
[σ]1
D1
τ1
σ→τ
D2
σ
τ
−→
D2
σD1
τ
[x : σ]1
D1
M : τ1
λx :σ.M : σ→τ
D2
P : σ
(λx :σ.M)P : τ
−→β
D2
P : σD1
M[P/x ] : τ
![Page 24: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/24.jpg)
The Formulas-as-Types notion of Construction (Howard1980)
Contribution of Tait (1965):Cut-elimination in logic = β-reduction in typed λ-calculus.
[σ]1
D1
τ1
σ→τ
D2
σ
τ
−→
D2
σD1
τ
[x : σ]1
D1
M : τ1
λx :σ.M : σ→τ
D2
P : σ
(λx :σ.M)P : τ
−→β
D2
P : σD1
M[P/x ] : τ
![Page 25: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/25.jpg)
The Formulas-as-Types notion of Construction (Howard1980)
Contribution of Tait (1965):Cut-elimination in logic = β-reduction in typed λ-calculus.
[σ]1
D1
τ1
σ→τ
D2
σ
τ
−→
D2
σD1
τ
[x : σ]1
D1
M : τ1
λx :σ.M : σ→τ
D2
P : σ
(λx :σ.M)P : τ
−→β
D2
P : σD1
M[P/x ] : τ
![Page 26: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/26.jpg)
Formulas-as-Types: proof theory and type theory
proof theory type theory
termination of cut-elimination ⇔ SN of β-reductionevery proof can be made cut-free ⇔ WN of β-reduction
disjunction property ⇐ CR and WNof β-reductionexistence property ⇐ CR and WN of β-reduction
SN = strong normalization,WN = weak normalization,CR = confluence
![Page 27: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/27.jpg)
Formulas-as-Types: Arithmetic
Extend with recursor / induction:
F : P(0) G : ∀n(P(x)→ P(S(x)))
R F G : ∀n(P(x))
R F G 0 →ι F
R F G (S x) →ι G x (R F G x)
![Page 28: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/28.jpg)
Formulas-as-Types: Arithmetic
Extend with recursor / induction:
F : P(0) G : ∀n(P(x)→ P(S(x)))
R F G : ∀n(P(x))
R F G 0 →ι F
R F G (S x) →ι G x (R F G x)
![Page 29: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/29.jpg)
Formulas-as-Types: Inductive Types
Martin-Lof (Scott): take well-founded induction as basic typeforming principle.⇒ Induction principle⇒ Recursion principle (well-founded)
Inductive List (A : Set) : Set
nil : List
cons : A -> List -> List
F : P(nil) G : ∀a:A∀l : ListA (P(l)→ P(cons a l))
R F G : ∀l : ListA P(l)
If P(x) is a proposition: “proof by induction”If P(x) is a set-type: “function def. by well-founded recursion”
![Page 30: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/30.jpg)
Formulas-as-Types: Inductive Types
Martin-Lof (Scott): take well-founded induction as basic typeforming principle.⇒ Induction principle⇒ Recursion principle (well-founded)
Inductive List (A : Set) : Set
nil : List
cons : A -> List -> List
F : P(nil) G : ∀a:A∀l : ListA (P(l)→ P(cons a l))
R F G : ∀l : ListA P(l)
If P(x) is a proposition: “proof by induction”If P(x) is a set-type: “function def. by well-founded recursion”
![Page 31: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/31.jpg)
Formulas-as-Types: Inductive Types
Martin-Lof (Scott): take well-founded induction as basic typeforming principle.⇒ Induction principle⇒ Recursion principle (well-founded)
Inductive List (A : Set) : Set
nil : List
cons : A -> List -> List
F : P(nil) G : ∀a:A∀l : ListA (P(l)→ P(cons a l))
R F G : ∀l : ListA P(l)
If P(x) is a proposition: “proof by induction”If P(x) is a set-type: “function def. by well-founded recursion”
![Page 32: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/32.jpg)
Formulas-as-Types: Inductive Types
Martin-Lof (Scott): take well-founded induction as basic typeforming principle.⇒ Induction principle⇒ Recursion principle (well-founded)
Inductive List (A : Set) : Set
nil : List
cons : A -> List -> List
F : P(nil) G : ∀a:A∀l : ListA (P(l)→ P(cons a l))
R F G : ∀l : ListA P(l)
If P(x) is a proposition: “proof by induction”If P(x) is a set-type: “function def. by well-founded recursion”
![Page 33: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/33.jpg)
Formulas-as-Types: Impredicativity
Girard has extended the formulas-as-types interpretation to higherorder logic.Higher order logic: ∀P : A→Prop. ∀x : A.P x → P xPolymorphic types: ∀A : Set.A→ A
Combining all these ideas: the type theory of the proof assistantCoq:
I inductive types
I dependent types
I impredicativity (higher order logic)
The SN proof of the type theory of Coq requires stronglyinaccessible cardinals.
![Page 34: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/34.jpg)
Formulas-as-Types: Impredicativity
Girard has extended the formulas-as-types interpretation to higherorder logic.Higher order logic: ∀P : A→Prop. ∀x : A.P x → P xPolymorphic types: ∀A : Set.A→ ACombining all these ideas: the type theory of the proof assistantCoq:
I inductive types
I dependent types
I impredicativity (higher order logic)
The SN proof of the type theory of Coq requires stronglyinaccessible cardinals.
![Page 35: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/35.jpg)
Formulas-as-Types: De Bruijn
![Page 36: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/36.jpg)
The two roles of a proof in mathematics
1. A proof explains: why?Goal: understanding
2. A proof convinces: is it true?Goal: verification
For (2) one can use computer support.
![Page 37: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/37.jpg)
Formulas as Types, Proofs as Objects
De Bruijn (re)invented the formulas-as-types principle (+/- 1968),emphasizing the proofs-as-objects aspect.
![Page 38: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/38.jpg)
Formulas as Types, Proofs as Objects
Automath
Isomorphism T between (names of) formulas and the types oftheir proofs:
Γ `logic ϕ iff Γ `type theory M : T (ϕ)
M codes (as a λ-term) the logical derivation of ϕ.
Γ consists of
I declarations x : A of the free variables
I assumptions, of the form y : T (ψ)
I proven lemmas are definitions, stored as y := p : T (ψ)(y is a name for the proof p of ψ).
Consequence:
proof checking = type checking
![Page 39: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/39.jpg)
Formulas as Types, Proofs as Objects
Automath
Isomorphism T between (names of) formulas and the types oftheir proofs:
Γ `logic ϕ iff Γ `type theory M : T (ϕ)
M codes (as a λ-term) the logical derivation of ϕ.Γ consists of
I declarations x : A of the free variables
I assumptions, of the form y : T (ψ)
I proven lemmas are definitions, stored as y := p : T (ψ)(y is a name for the proof p of ψ).
Consequence:
proof checking = type checking
![Page 40: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/40.jpg)
Formulas as Types, Proofs as Objects
Automath
Isomorphism T between (names of) formulas and the types oftheir proofs:
Γ `logic ϕ iff Γ `type theory M : T (ϕ)
M codes (as a λ-term) the logical derivation of ϕ.Γ consists of
I declarations x : A of the free variables
I assumptions, of the form y : T (ψ)
I proven lemmas are definitions, stored as y := p : T (ψ)(y is a name for the proof p of ψ).
Consequence:
proof checking = type checking
![Page 41: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/41.jpg)
Formulas as Types, Proofs as Objects
Automath
Isomorphism T between (names of) formulas and the types oftheir proofs:
Γ `logic ϕ iff Γ `type theory M : T (ϕ)
M codes (as a λ-term) the logical derivation of ϕ.Γ consists of
I declarations x : A of the free variables
I assumptions, of the form y : T (ψ)
I proven lemmas are definitions, stored as y := p : T (ψ)(y is a name for the proof p of ψ).
Consequence:
proof checking = type checking
![Page 42: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/42.jpg)
Automath as a Logical Framework
Automath is a language for dealing with the basic mathematicallinguistic constructions, like substitution, variable binding, creationand unfolding of definitions etc.
A user is free to add the logical rules that he/she wishes⇒ Automath is a logical framework, where the user can do his/herown logic (or any other formal system).
![Page 43: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/43.jpg)
Automath as a Logical Framework
Automath is a language for dealing with the basic mathematicallinguistic constructions, like substitution, variable binding, creationand unfolding of definitions etc.
A user is free to add the logical rules that he/she wishes⇒ Automath is a logical framework, where the user can do his/herown logic (or any other formal system).
![Page 44: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/44.jpg)
Logical Framework encoding versus direct encoding
proof formula
direct encoding λx :A.x A→ALF encoding imp intr A Aλx :T A.x T (A⇒ A)
Needed:
prop : type
⇒ : prop→prop→prop
T : prop→type
imp intr : ΠA,B : prop. (T A→ T B)→ T(A⇒ B)
imp el : ΠA,B : prop.T(A⇒ B)→ T A→ T B.
![Page 45: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/45.jpg)
Logical Framework encoding versus direct encoding
proof formula
direct encoding λx :A.x A→ALF encoding imp intr A Aλx :T A.x T (A⇒ A)
Needed:
prop : type
⇒ : prop→prop→prop
T : prop→type
imp intr : ΠA,B : prop. (T A→ T B)→ T(A⇒ B)
imp el : ΠA,B : prop.T(A⇒ B)→ T A→ T B.
![Page 46: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/46.jpg)
Automath as a Logical Framework
The user is responsible for the logical rules.De Bruijn’s version of the formulas-as-types principle:
Γ `L ϕ iff ΓL, Γ `type theory M : T (ϕ)
where L is a logic, ΓL is the context in which the constructions ofthe logic L have been declared.Choice and trade-off: Which logical constructions do you put inthe type theory and which constructions do you declareaxiomatically in the context?
![Page 47: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/47.jpg)
Automath as a Logical Framework
The user is responsible for the logical rules.De Bruijn’s version of the formulas-as-types principle:
Γ `L ϕ iff ΓL, Γ `type theory M : T (ϕ)
where L is a logic, ΓL is the context in which the constructions ofthe logic L have been declared.
Choice and trade-off: Which logical constructions do you put inthe type theory and which constructions do you declareaxiomatically in the context?
![Page 48: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/48.jpg)
Automath as a Logical Framework
The user is responsible for the logical rules.De Bruijn’s version of the formulas-as-types principle:
Γ `L ϕ iff ΓL, Γ `type theory M : T (ϕ)
where L is a logic, ΓL is the context in which the constructions ofthe logic L have been declared.Choice and trade-off: Which logical constructions do you put inthe type theory and which constructions do you declareaxiomatically in the context?
![Page 49: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/49.jpg)
Language theoretic studies
Metamathematics is about metatheory for logical systems (sequentcalculus, natural deduction, . . . )
but also about the
Metalanguage that you actually formally describe yourformal systems in.
I How do you really do renaming of variables, capture avoidingsubstitution, instantiation of a quantifier, . . . .
I De Bruijn index representation: λ 1 (λ 1 2) denotesλx .x (λy .y x).
I The “higher order” part of f.o.l. is in the logical framework(meta-language): ∀D : (D → prop)→ prop(This was already how Church did it in 1940.)
![Page 50: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/50.jpg)
Language theoretic studies
Metamathematics is about metatheory for logical systems (sequentcalculus, natural deduction, . . . ) but also about the
Metalanguage that you actually formally describe yourformal systems in.
I How do you really do renaming of variables, capture avoidingsubstitution, instantiation of a quantifier, . . . .
I De Bruijn index representation: λ 1 (λ 1 2) denotesλx .x (λy .y x).
I The “higher order” part of f.o.l. is in the logical framework(meta-language): ∀D : (D → prop)→ prop(This was already how Church did it in 1940.)
![Page 51: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/51.jpg)
Language theoretic studies
Metamathematics is about metatheory for logical systems (sequentcalculus, natural deduction, . . . ) but also about the
Metalanguage that you actually formally describe yourformal systems in.
I How do you really do renaming of variables, capture avoidingsubstitution, instantiation of a quantifier, . . . .
I De Bruijn index representation: λ 1 (λ 1 2) denotesλx .x (λy .y x).
I The “higher order” part of f.o.l. is in the logical framework(meta-language): ∀D : (D → prop)→ prop(This was already how Church did it in 1940.)
![Page 52: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/52.jpg)
Language theoretic studies
Metamathematics is about metatheory for logical systems (sequentcalculus, natural deduction, . . . ) but also about the
Metalanguage that you actually formally describe yourformal systems in.
I How do you really do renaming of variables, capture avoidingsubstitution, instantiation of a quantifier, . . . .
I De Bruijn index representation: λ 1 (λ 1 2) denotesλx .x (λy .y x).
I The “higher order” part of f.o.l. is in the logical framework(meta-language): ∀D : (D → prop)→ prop(This was already how Church did it in 1940.)
![Page 53: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/53.jpg)
Extracting Programs from constructive proofs
A proof p of∀x : A∃y : B R(x , y)
contains an algorithmf : A→ B
and a proof q of ∀x : A.R(x , f (x)).The specification ∀x : A.∃y : B.R(x , y), once realised (proven)produces a program that satisfies the spec.
![Page 54: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/54.jpg)
Programming with constructive proofs
Example: sorting a list of natural numbers
sort : ListN → ListN
More refined spec. (output is sorted):
sort : ListN → ∃y :ListN(Sorted(y))
Even more refined spec. (output is a permutation of the input):
sort : ∀x :ListN ∃y :ListN(Sorted(y) ∧ Perm(x , y))
The proof sort contains a sorting algorithm.
![Page 55: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/55.jpg)
Programming with constructive proofs
Example: sorting a list of natural numbers
sort : ListN → ListN
More refined spec. (output is sorted):
sort : ListN → ∃y :ListN(Sorted(y))
Even more refined spec. (output is a permutation of the input):
sort : ∀x :ListN ∃y :ListN(Sorted(y) ∧ Perm(x , y))
The proof sort contains a sorting algorithm.
![Page 56: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/56.jpg)
Programming with constructive proofs
Example: sorting a list of natural numbers
sort : ListN → ListN
More refined spec. (output is sorted):
sort : ListN → ∃y :ListN(Sorted(y))
Even more refined spec. (output is a permutation of the input):
sort : ∀x :ListN ∃y :ListN(Sorted(y) ∧ Perm(x , y))
The proof sort contains a sorting algorithm.
![Page 57: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/57.jpg)
Programming with constructive proofs
Extracting the computational content from a proof.
sort : ∀x :ListN ∃y :ListN(Sorted(y) ∧ Perm(x , y))
Distinguishing data and proofs:
sort :
computation︷ ︸︸ ︷Πx :ListN Σy :ListN (Sorted(y) ∧ Perm(x , y))︸ ︷︷ ︸
specification
![Page 58: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/58.jpg)
Programming with constructive proofs
Extracting the computational content from a proof.
sort : ∀x :ListN ∃y :ListN(Sorted(y) ∧ Perm(x , y))
With data-proof distinction and program extraction:
sort : Πx :ListN Σy :ListNSorted(y) ∧ Perm(x , y))
������
?
sort : ListN → ListN
correct : ∀x :ListN(Sorted(sort(x)) ∧ Perm(x , sort(x)))
![Page 59: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/59.jpg)
Formulas-as-Types, Proofs-as-Terms in Theorem Proving
Proof checking = Type checking
There is a “type check” algorithm TC:
TC(p) 7→ A if p : A
TC(p) 7→ fail if p not typable
Proof search (Theorem Proving) =interactive search (construction) of a term p : A.
![Page 60: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/60.jpg)
Some Conclusions
Is type theory necessarily constructive?“Constructive notion of proof 6= notion of constructive proof”(De Bruijn)
Notion of constructive proof: Brouwer; content of axioms and rules
Constructive notion of proof: Hilbert; how to manipulate axiomsand rules
![Page 61: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/61.jpg)
Some Conclusions
Is type theory necessarily constructive?“Constructive notion of proof 6= notion of constructive proof”(De Bruijn)
Notion of constructive proof: Brouwer; content of axioms and rules
Constructive notion of proof: Hilbert; how to manipulate axiomsand rules
![Page 62: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/62.jpg)
Further refinements of Formulas-as-Types
Extend to classical logicI ∀x : N ∃y : N R(x , y) (with R(x , y) atomic) is provable
classically iff provable constructivelyI transform classical proof to constructive oneI extract computational content from classical proof directly
I computational content of the double negation rule?cut-elimination is not confluent so: call-by-value vs.call-by-nameCPS: “jumping out of a loop”:
mult(l) := if empty(l) then 1 else l [0] ∗mult (tail(l))
![Page 63: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/63.jpg)
Further refinements of Formulas-as-Types
Extend to classical logicI ∀x : N ∃y : N R(x , y) (with R(x , y) atomic) is provable
classically iff provable constructivelyI transform classical proof to constructive oneI extract computational content from classical proof directly
I computational content of the double negation rule?cut-elimination is not confluent so: call-by-value vs.call-by-nameCPS: “jumping out of a loop”:
mult(l) := if empty(l) then 1 else l [0] ∗mult (tail(l))
![Page 64: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/64.jpg)
Further refinements of Formulas-as-Types
Extend to (classical) sequent calculus
I Replace sequents Γ ` ∆ by Γ ` A|∆ and Γ|A ` ∆.
I Proof terms can distinguish between forward and backwardproofs. (Record the “proof process”.)
![Page 65: A review of the Curry-Howard-De Bruijn formulas-as-types ...herman/slidesMLNL2009.pdf · I Realism: But mathematics also has a relation with the real world! Also in nitary mathematics!](https://reader033.vdocuments.mx/reader033/viewer/2022050101/5f406d365ff754631a742c15/html5/thumbnails/65.jpg)
Further refinements of Formulas-as-Types and ProgramExtraction
Extract programs from proofs in analysis.I Exact real arithmetic
I Not: determine output precision on the basis of input precision(interval arithmetic)
I But: Let the requited output precision determiine the requiredinput precision.