A short overview of Type Theory
Yves Bertot June 2015
1 / 36
A short overview of Type Theory Yves Bertot June 2015 1 / 36 - - PowerPoint PPT Presentation
A short overview of Type Theory Yves Bertot June 2015 1 / 36 Motivation for types You know types, for instance in C int x = 3; Type errors are detected at compile-time Type verification removes errors from run-time errors Not
1 / 36
2 / 36
◮ Three constructs ◮ function descriptions, function calls, variables ◮ Only one input to functions ◮ Only one output to functions
◮ Higher order: programs are values ◮ No control on memory usage ◮ several possible evaluation strategies 3 / 36
◮ Several argument functions are a particular case
4 / 36
5 / 36
6 / 36
7 / 36
8 / 36
9 / 36
◮ provide documentation on programs,
10 / 36
11 / 36
12 / 36
13 / 36
14 / 36
◮ Curry-Howard isomorphism, types-as-propositions,
15 / 36
16 / 36
17 / 36
18 / 36
◮ Type inference ◮ Polymorphism ◮ General recursion
◮ Universal quantification ◮ Proofs by induction ◮ Guaranteeing computation termination 19 / 36
20 / 36
◮ 0 : nat (represents 0) ◮ S : nat → nat (represents successor), ◮ rec nat
◮ rec nat v f O = v ◮ rec nat v f (S n) = f n (rec nat P v f n)
◮ rec nat : t → (nat → t → t) → nat → t, for any type t,
21 / 36
◮ subtraction is also a comparison test, minus x y = 0 si x ≤ y,
22 / 36
◮ leaf : bin, ◮ node : nat → bin → bin → bin, 23 / 36
◮ rec bin has three arguments (2+1), rec bin f1 f2 x, is
◮ f1 is a value of type t, ◮ f2 has (3+2) arguments, ◮ 3 is the number of arguments of node, ◮ 2 is the number of arguments of node in type bin, ◮ extra arguments are values for recursive calls
24 / 36
25 / 36
◮ f 0 has type A 0, ◮ f 1 has type A 1, ◮ f 2 has typeA 2, ◮ and so on,
26 / 36
27 / 36
28 / 36
29 / 36
◮ even0 :
◮ even2 :
30 / 36
31 / 36
◮ rec nat P v f O = v ◮ rec nat P v f (S n) = f n (rec nat P v f n)
◮ Need a type family P : nat → Type, ◮ The value for 0 must be in P 0, ◮ The value for S n must be in P (S n), ◮ The value of any recursive call on n must be in P n,
32 / 36
◮ hleaf :
◮ hnode :
33 / 36
◮ even0:
◮ even2:
34 / 36
35 / 36
◮ Defining only simply typed functions ◮ One uses universal quantifiactions only in logical formula ◮ The only type families one considers are inductive predicates ◮ Tactics take care of constructing the most complex terms
◮ Make types less cumbersome (esp. for equality) ◮ Integrate automatic proof search ◮ Applications in reliable software development 36 / 36