Formalizing Proofs
Formalizing Proofs
John Harrison
Intel Corporation
15 April 2012
1
Summary
2
I: Formalization and Computers
3
100 years since Principia Mathematica
4
100 years since Principia Mathematica
4
100 years since Principia Mathematica
4
100 years since Principia Mathematica
4
100 years since Principia Mathematica
4
The importance of computers for formal proof
Computers can both help with formal proof and give us new
reasons to be interested in it:
5
The importance of computers for formal proof
Computers can both help with formal proof and give us new
reasons to be interested in it:
I Computers are expressly designed for performing formal
manipulations quickly and without error, so can be used to
check and partly generate formal proofs.
5
The importance of computers for formal proof
Computers can both help with formal proof and give us new
reasons to be interested in it:
I Computers are expressly designed for performing formal
manipulations quickly and without error, so can be used to
check and partly generate formal proofs.
I Correctness questions in computer science (hardware,
programs, protocols etc.) generate a whole new array of
difficult mathematical and logical problems where formal proof
can help.
5
The importance of computers for formal proof
Computers can both help with formal proof and give us new
reasons to be interested in it:
I Computers are expressly designed for performing formal
manipulations quickly and without error, so can be used to
check and partly generate formal proofs.
I Correctness questions in computer science (hardware,
programs, protocols etc.) generate a whole new array of
difficult mathematical and logical problems where formal proof
can help.
Because of these dual connections, interest in formal proofs is
strongest among computer scientists, but some ‘mainstream’
mathematicians are becoming interested too.
5
Russell was an early fan of mechanized formal proof
6
Russell was an early fan of mechanized formal proof
6
Russell was an early fan of mechanized formal proof
6
Formalization in current mathematics
7
Formalization in current mathematics
7
Formalization in current mathematics
7
Formalization in current mathematics
7
Mathematics is reduced to sets
8
Symbolism is important
9
Formalization is the key to rigour
10
Mathematicians don’t use logical symbols
11
Mathematicians don’t do formal proofs . . .
12
. . . and the few people that do end up regretting it
13
Are proofs in doubt?
Mathematical proofs are subjected to peer review, but errors often
escape unnoticed.
“Professor Offord and I recently committed ourselves to
an odd mistake (Annals of Mathematics (2) 49, 923,
1.5). In formulating a proof a plus sign got omitted,
becoming in effect a multiplication sign. The resulting
false formula got accepted as a basis for the ensuing
fallacious argument. (In defence, the final result was
known to be true.)” (Littlewood, Miscellany)
14
Even elegant textbook proofs can be wrong
15
Most doubtful informal proofs
16
4-colour Theorem
17
Formal verification
18
The FDIV bug
19
II: Theorem Proving Techology
20
Theorem provers vs. computer algebra systems
21
Limited expressivity in CASs
22
Unclear expressions in CASs
23
Lack of rigour in many CASs
CASs often apply simplifications even when they are not strictly
valid.
Hence they can return wrong results.
Consider the evaluation of this integral in Maple:
∞ 2
e −(x−1)
Z
√ dx
0 x
24
An integral in Maple
> int(exp(-(x-t)^2)/sqrt(x), x=0..infinity);
1 1 1 t2 2
3(t 2 ) 4 π 2 2 2 e 2 K 3 ( t2 )
1 1 t2
1 2
e −t
2
−
t2
4
+ (t 2 ) 4 π 2 2 2 e 2 K 7 ( t2 )
1 4
2 1
π2
> subs(t=1,%);
1 1 1 1 1 1
e −1 −3π 2 2 2 e 2 K 3 ( 12 )+π 2 2 2 e 2 K 7 ( 12 )
1 4 4
2 1
π2
> evalf(%);
0.4118623312
1.973732150
25
Early research in automated reasoning
26
A theorem in geometry (1)
Example of AI approach in action:
A
A
A
A
A
A
A
A
B AC
27
A theorem in geometry (2)
Drop perpendicular meeting BC at a point D:
A
A
A
A
A
A
A
A
B D
AC
and then use the fact that the triangles ABD and ACD are
congruent.
28
A theorem in geometry (3)
29
The Robbins Conjecture (1)
x +y = y +x
(x + y ) + z = x + (y + z)
n(n(x) + y ) + n(n(x) + n(y )) = x
30
The Robbins Conjecture (2)
31
What can be automated?
32
Some specific theories
33
Quantifier elimination
34
Interactive theorem proving
35
Who checks the checker?
36
Prover architecture
37
HOL Light
HOL Light is an extreme case of the LCF approach. The entire
critical core is 430 lines of code:
I 10 rather simple primitive inference rules
I 2 conservative definitional extension principles
I 3 mathematical axioms (infinity, extensionality, choice)
Arguably, HOL Light is the computer-age version of Principia:
I The logical basis is simple type theory, which was distilled
(Ramsey, Chwistek, Church) from PM’s original logic.
I Everything, even arithmetic on numbers, is done from first
principles by reduction to the primitive logical basis.
A simplified version of the core has itself been formally proved.
38
Choice of foundations
39
Prover architecture
40
Proof style
41
A few notable general-purpose theorem provers
Different systems with various strengths and weaknesses:
I ACL2
I Coq
I HOL (HOL Light, HOL4, ProofPower, HOL Zero)
I IMPS
I Isabelle
I Mizar
I Nuprl
I PVS
See Freek Wiedijk’s book The Seventeen Provers of the World
(Springer-Verlag lecture notes in computer science volume √
3600)
for descriptions of many systems and a proof in each that 2 is
irrational.
42
III: Applications
43
Recent formal proofs in pure mathematics
44
Recent formal proofs in computer system verification
Some successes for verification using theorem proving technology:
I Microcode algorithms for floating-point division, square root
and several transcendental functions on Intel Itanium
processor family (John Harrison, HOL Light)
I CompCert verified compiler from significant subset of the C
programming language into PowerPC assembler (Xavier Leroy
et al., Coq)
I Designed-for-verification version of L4 operating system
microkernel (Gerwin Klein et al., Isabelle/HOL).
Again, these indicate that complex and subtle computer systems
can be verified, but significant manual effort was needed, perhaps
tens of person-years for L4.
45
Some challenges and open problems
46
The Kepler conjecture
47
The response of the reviewers
After a full four years of deliberation, the reviewers returned:
“The news from the referees is bad, from my perspective.
They have not been able to certify the correctness of the
proof, and will not be able to certify it in the future,
because they have run out of energy to devote to the
problem. This is not what I had hoped for.
Fejes Toth thinks that this situation will occur more and
more often in mathematics. He says it is similar to the
situation in experimental science — other scientists
acting as referees can’t certify the correctness of an
experiment, they can only subject the paper to
consistency checks. He thinks that the mathematical
community will have to get used to this state of affairs.”
48
The birth of Flyspeck
49
Flyspeck
The formalization effort has been running for a few years now with
a significant group of people involved, some doing their PhD on
Flyspeck-related formalization.
In parallel, Hales has simplified the informal proof using ideas from
Marchal, significantly cutting down on the formalization work.
50
Flyspeck: current status
51