A Mini Course on Martin-L¨
- f Type Theory
Algebras, Coalgebras, and Interactive Theorem Proving
Anton Setzer Swansea University, Swansea UK Lisbon, 9 September 2015
Anton Setzer Mini Course on Martin-L¨
- f Type Theory
1/ 136
A Mini Course on Martin-L of Type Theory Algebras, Coalgebras, and - - PowerPoint PPT Presentation
A Mini Course on Martin-L of Type Theory Algebras, Coalgebras, and Interactive Theorem Proving Anton Setzer Swansea University, Swansea UK Lisbon, 9 September 2015 Anton Setzer Mini Course on Martin-L of Type Theory 1/ 136 Type Theory
Anton Setzer Mini Course on Martin-L¨
1/ 136
Anton Setzer Mini Course on Martin-L¨
2/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
3/ 136
Type Theory and Interactive Theorem Proving
◮ Guarantee that proofs are correct. ◮ Especially a problem in software verification (lots of boring cases). ◮ Can be essential in critical software. ◮ Help of machine in constructing proofs (proof search). ◮ Ideally the mathematician can concentrate on the key ideas and
◮ Ideally one could have a machine assisted proof in demonstrating
◮ Desire to have systems as powerful as computer algebra systems
Anton Setzer Mini Course on Martin-L¨
4/ 136
Type Theory and Interactive Theorem Proving
◮ Works only for restricted theories, which often need to be
◮ In Automated Theorem Proving hints in the form of intermediate
◮ In Interactive Theorem Proving proof tactics and automated
◮ It’s like relationship between the idea of a program and
◮ The machine doesn’t allow any gaps. Anton Setzer Mini Course on Martin-L¨
5/ 136
Type Theory and Interactive Theorem Proving
◮ help obtaining correct programs, ◮ help writing programs.
Anton Setzer Mini Course on Martin-L¨
6/ 136
Type Theory and Interactive Theorem Proving
◮ help obtaining correct programs, ◮ help writing programs.
Anton Setzer Mini Course on Martin-L¨
6/ 136
Type Theory and Interactive Theorem Proving
◮ help obtaining correct programs, ◮ help writing programs.
Anton Setzer Mini Course on Martin-L¨
6/ 136
Type Theory and Interactive Theorem Proving
◮ help obtaining correct programs, ◮ help writing programs.
Anton Setzer Mini Course on Martin-L¨
6/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
7/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
8/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
9/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
10/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
11/ 136
Type Theory and Interactive Theorem Proving
Anton Setzer Mini Course on Martin-L¨
12/ 136
Type Theory and Interactive Theorem Proving
◮ Formalisation of four colour problem. ◮ Microsoft has invested in it (but development happening at INRIA,
◮ Project of proving Kepler conjecture in it. ◮ Inspired Voevodsky to develop Homotopy Type Theory.
Anton Setzer Mini Course on Martin-L¨
13/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
14/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
15/ 136
Key Philosophical Principles of Martin-L¨
◮ We don’t want to have a proof of Fermat’s last theorem and a counter
Anton Setzer Mini Course on Martin-L¨
16/ 136
Key Philosophical Principles of Martin-L¨
◮ Because for every n : N we can construct a proof of A(n) by using
Anton Setzer Mini Course on Martin-L¨
17/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
18/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
19/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
20/ 136
Key Philosophical Principles of Martin-L¨
◮ that certain objects are elements of that type
◮ and how to form from an element a : A an element of another
Anton Setzer Mini Course on Martin-L¨
21/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
22/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
23/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
24/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
25/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
26/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
27/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
28/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
29/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
30/ 136
Key Philosophical Principles of Martin-L¨
◮ An indirect proof is as follows: itmm In order to proof A assume ¬A ◮ Then derive a contradiction ◮ So ¬A is false (i.e. we have ¬¬A. ◮ By stability we get A.
◮ If we have ¬¬A we have a method which from a proof of ¬A computes
◮ This does not give as a method to compute a proof of A. Anton Setzer Mini Course on Martin-L¨
31/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
32/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
33/ 136
Key Philosophical Principles of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
34/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
35/ 136
Setup of Martin-L¨
◮ A is a type written as
◮ A and B are equal types written as
◮ a is an element of type A written as
◮ a, b are equal elements of type A written as
Anton Setzer Mini Course on Martin-L¨
36/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
37/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
38/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
39/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
40/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
41/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
42/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
43/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
44/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
45/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
46/ 136
Setup of Martin-L¨
◮ Canonical elements of N are for instance
Anton Setzer Mini Course on Martin-L¨
47/ 136
Setup of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
48/ 136
Setup of Martin-L¨
◮ In order to check
◮ If they start with different constructors, s and t are different.
◮ If they have the same constructor, e.g. s −
Anton Setzer Mini Course on Martin-L¨
49/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
50/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
51/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
52/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
53/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
54/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
55/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
56/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
57/ 136
Basic Types in Martin-L¨
◮ C(x) is a set depending on x : B. ◮ instantiate x = tt and get C(tt).
◮ Instead of saying
◮ Then we can apply C to tt and obtain
Anton Setzer Mini Course on Martin-L¨
58/ 136
Basic Types in Martin-L¨
◮ It treats the collection of sets as an entity, at least as if one considers it
◮ The foundations of Martin-L¨
Anton Setzer Mini Course on Martin-L¨
59/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
60/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
61/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
62/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
63/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
64/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
65/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
66/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
67/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
68/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
69/ 136
Basic Types in Martin-L¨
◮ an a : A ◮ together with a b : B a
Anton Setzer Mini Course on Martin-L¨
70/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
71/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
72/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
73/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
74/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
75/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
76/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
77/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
78/ 136
Basic Types in Martin-L¨
◮ an set U : Set of codes for sets, ◮ a decoding function T : U → Set. Anton Setzer Mini Course on Martin-L¨
79/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
80/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
81/ 136
Basic Types in Martin-L¨
Anton Setzer Mini Course on Martin-L¨
82/ 136
Basic Types in Martin-L¨
◮ Second argument is indexed over (T a). ◮ Index set (T a) for second argument depends on the T applied to first
◮ T(
◮ (T a), ◮ (T (b x))(x:T a).
Anton Setzer Mini Course on Martin-L¨
83/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
84/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
85/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
86/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
87/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
88/ 136
The Logical Framework
◮ either λ-abstraction, i.e. we can define
◮ Requires that b : B depending on x : A. ◮ Note that the type B of b depends on x : A. ◮ or by writing
Anton Setzer Mini Course on Martin-L¨
89/ 136
The Logical Framework
◮ E.g., if f : (x : A) → B and a : A, then f a : B[x := a]. Anton Setzer Mini Course on Martin-L¨
90/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
91/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
92/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
93/ 136
The Logical Framework
◮ Remember that ∀x : A.B is another notation for ∀x : A.B. Anton Setzer Mini Course on Martin-L¨
94/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
95/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
96/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
97/ 136
The Logical Framework
◮ using this rule we can prove everything, especially false formulas.
✿✿✿✿✿✿✿✿✿
Anton Setzer Mini Course on Martin-L¨
98/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
99/ 136
The Logical Framework
◮ So besides judgements A : Set we have as well judgements of the form
◮ One rule will especially express
◮ Elements of Type are types, elements of Set are small types. Anton Setzer Mini Course on Martin-L¨
100/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
101/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
102/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
103/ 136
The Logical Framework
Anton Setzer Mini Course on Martin-L¨
104/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
105/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
106/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
107/ 136
Inductive Data Types (Algebras) in Type Theory
◮ However, it is difficult to understand A, if we have negative
◮ Example:
◮ What is the least set A having a constructor
Anton Setzer Mini Course on Martin-L¨
108/ 136
Inductive Data Types (Algebras) in Type Theory
◮ If we ◮ have constructed some elements of A already, ◮ find a function f : A → A, and ◮ add C f to A,
◮ In fact, the termination checker issues a warning, if we define A as
◮ We shouldn’t make use of such definitions. Anton Setzer Mini Course on Martin-L¨
109/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
110/ 136
Inductive Data Types (Algebras) in Type Theory
◮ If we add a :: l to NList, the reason for adding it (namely l : NList) is
◮ So we can “construct” the set NList by ◮ starting with the empty set, ◮ adding [ ] and ◮ closing it under :: whenever possible.
Anton Setzer Mini Course on Martin-L¨
111/ 136
Inductive Data Types (Algebras) in Type Theory
◮ either types which don’t make use of A ◮ or are A itself.
Anton Setzer Mini Course on Martin-L¨
112/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
113/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
114/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
115/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
116/ 136
Inductive Data Types (Algebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
117/ 136
Inductive Data Types (Algebras) in Type Theory
◮ in the Bintree example, when defining
Anton Setzer Mini Course on Martin-L¨
118/ 136
Inductive Data Types (Algebras) in Type Theory
◮ In the example of O, when defining
Anton Setzer Mini Course on Martin-L¨
119/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
120/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
121/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ Makes it difficult to use. Anton Setzer Mini Course on Martin-L¨
122/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
123/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ N as an algebra can be represented as introduction rules for N:
◮ Stream as a coalgebra can be expressed as as elimination rules for it:
Anton Setzer Mini Course on Martin-L¨
124/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
125/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
126/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ Allows to derive primitive recursion:
◮ Allows to derive primitive corecursion:
Anton Setzer Mini Course on Martin-L¨
127/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
128/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
129/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ Using primitive corecursion we can define more easily
Anton Setzer Mini Course on Martin-L¨
130/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ Equivalent to uniqueness of arrows with respect to propositional
◮ How to dualise dependent primitive recursion? Anton Setzer Mini Course on Martin-L¨
131/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ Those schemata are usually not derivable in weakly final coalgebras. Anton Setzer Mini Course on Martin-L¨
132/ 136
Coinductive Data Types (Coalgebras) in Type Theory
◮ An f : A → B is any program which if applied to a : A returns some
Anton Setzer Mini Course on Martin-L¨
133/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
134/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
135/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136
Coinductive Data Types (Coalgebras) in Type Theory
Anton Setzer Mini Course on Martin-L¨
136/ 136