96
Graph Coloring and Machine Proofs in Computer Science, 1977-2017 Andrew W. Appel Princeton University 1

Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Graph Coloring andMachine Proofs in

Computer Science, 1977-2017

Andrew W. AppelPrinceton University

1

Page 2: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Can it really be a proof if you can’t check it by machine?

2

Page 3: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Alfred B. Kempe, 1849-1922

In 1876, Kempe’s Universality Theorem: for an arbitrary algebraic plane curve, a linkage can be constructed that draws the curve.

3

Barrister of ecclesiastical law; mathematician

Oops! There was a bug in the proof.

Finally proved in 2002 by Michael Kapovich and John J. Millson

Page 4: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Alfred B. Kempe, 1849-1922

In 1879, proof of the 4-color theorem: every planar graph can be colored using at most 4 colors.

(Any nodes connected

by an edge must have

different colors.)

4

f

e

b m

cd

kj

h

g

Barrister of ecclesiastical law; mathematician

Page 5: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Alfred B. Kempe 1879

6-color theorem:

Every planar graph is 6-colorable.

5-color theorem:

Every planar graph is 5-colorable.

4-color theorem:

Every planar graph is 4-colorable.

5

Percy J. Heawoodfound a bug in the proof, 1890

Page 6: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Alfred B. Kempe 1879

6-color theorem:

Every planar graph is 6-colorable.

6

Proof:1. Every planar graph has at least one node of degree <6

(by Euler’s polyhedron formula): V−E+F = 2, average degree < 6

2. If you remove one node from a planar graph,what remains is a planar graph.

3. This leads to an algorithm for coloring graphs . . .

Page 7: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Kempe’s graph-coloring algorithm

To 6-color a planar graph:

1. Every planar graph has at least one vertex of degree ≤ 5.

2. Remove this vertex.

3. Color the rest of the graph with a recursive call to Kempe’s algorithm.

4. Put the vertex back. It is adjacent to at most 5 vertices, which use up at most 5 colors from your “palette.” Use the 6th color for this vertex.

7

Page 8: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 6-color this graph

8

f

e

b m

cd

kj

h

g

Page 9: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 6-color this graph

9

f

e

b m

cd

kj

h

g This node

has degree < 6 ;

remove it!

Page 10: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 6-color this graph

10

f

e

b m

cd

kj

h

g

Now, by induction, supposewe could color the rest ofthe graph

Page 11: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the residual graph

11

f

e

b m

cd

kj

h

gFind a color for this

node that’s not already

used in an adjacent node

Now, by induction, supposewe could color the rest ofthe graph

We can surelyfind a color for c

Page 12: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Put back the node c, and color it

12

f

e

b m

cd

kj

h

g

Why did this work?Because when we removedeach node, at that time it had degree < 6.So when we put it back, it’s adjacentto at most 5 already-colored nodes.

Page 13: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Kempe’s 4-coloring algorithm

To 4-color a planar graph:

1. Find a vertex of degree ≤ 5 (there must be one)

2. Remove this vertex.

3. Color the rest of the graph with a recursive call to Kempe’s algorithm.

4. Put the vertex back.

13

These cases: easy; you can finda color not used by an adjacent node.

This case: use the method of “Kempe chains”

This case . . .

Page 14: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Kempe chains

14

b

dk

j

g

Suppose you are 4-coloring this graph:

f

h

k

u

?

Page 15: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Kempe’s 4-coloring algorithm

To 4-color a planar graph:

1. Find a vertex of degree ≤ 5 (there must be one)

2. Remove this vertex.

3. Color the rest of the graph with a recursive call to Kempe’s algorithm.

4. Put the vertex back.

15

These cases: easy

This case: use “Kempe chains”

This case: use “simultaneous Kempe chains”

Page 16: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Kempe’s 4-coloring algorithm

To 4-color a planar graph:

1. Find a vertex of degree ≤ 5 (there must be one)

2. Remove this vertex.

3. Color the rest of the graph with a recursive call to Kempe’s algorithm.

4. Put the vertex back.

16

These cases: easy

This case: use “Kempe chains”

“simultaneous Kempe chains”Heawood 1890

Page 17: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

5-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

6-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

17

Kempe 1879 Kempe 1879

Page 18: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Unavoidable sets

18

Illinois Journal of Mathematics1976 (received 1974)

Page 19: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Wernicke, Franklin, Lebesgue, Heesch

19

4-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

Heinrich Heesch1906-1995

“unavoidable set”

~1970: [paraphrase]

I estimate that computers

will be powerful enough someday,

to find an unavoidable set of

perhaps 10,000 reducible

configurations

of “reducible

configurations”

would prove

the 4-color

theorem

??

?

?

??

??

?

?

Page 20: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Appel and Haken

1972-1974: Let’s use computers to analyze unavoidable sets, and estimate,

(1) how many configurations might be in an unavoidable set of reducible configurations?

(2) in what year will future computers be fast enough to calculate this?

20

Page 21: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

21

Page 22: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Appel and Haken

1974: and the estimate is,

(1) about 2000 configurations

22

1974: and the estimate is,

(1) about 2000 configurations

(2) in the year 1972!

IBM System/370 Model 168, 1972

Page 23: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Appel and Haken and Koch

1974-1976: Calculate

(1) an unavoidable set of 1900 configs(using a version of Heesch’s“discharging” procedure)

(2) reducibility proofs for each config., using various reducibility algorithms (implemented with the assistance of C.S. PhD student John Koch)

23

Page 24: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Teletype model ASR-33 110 bits per second

24

Page 25: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Mathematical Games

25

Page 26: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

5-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

6-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

26

(a degree 5 node)

(degree 4) (degree 1)

4-color thmEvery planar graph contains at least 1 of these configurations:

“reduce”: Replace that configuration with a smaller config., color the remaining graph, put the node back, you can find a color for the node!

(and 1900 more)

Kempe 1879 Kempe 1879 Appel and Haken 1976

Page 27: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Math department postage meter

27

July 22, 1976

Page 28: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

My own contribution to the 4CT proofreading:

“[with] five of their children … Dorothea and Armin Haken, and Laurel, Peter, and Andrew Appel, they set to work [proofreading configurations from computer printouts]”

Robin Wilson, 2002 28

Dorothea HakenBlostein

(1959-)

Professor of C.S.Queens University

Laurel Appel(1962-2013)

Adjunct Assoc. Prof.of Biology

Wesleyan University

None.

two

Page 29: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Which part don’t you believe?

“Haken’s son Armin, by then a graduate student at … Berkeley, gave a lecture on the four-colour problem…. At the end, the audience split into two groups: the over-forties could not be convinced that a proof by computer was correct, while the under-forties could not be convinced that a proof containing 700 pages of hand calculations could be correct.”

29Princeton University Press 2002

Page 30: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

30

Kempe

Guthrie

Heawood

Birkhoff

Wernicke“unavoidable set”

“reducible”

Heesch

Appel, Haken “Every planar map

is 4-colorable”

“discharging” to

compute unavoidable set

Robertson, Sanders,Seymour, Thomas improved proof,

same basic recipe

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Page 31: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

31

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Another history1700 Leibniz1850 Babbage1920 Hilbert

Can we mechanize

mathematics?

1930 GödelTuring

Can we mechanize

mathematics?

Can we mechanize

mathematics?

Proof checking: yes

Proving: not quite

In particular, a short

theorem statement

might have a very

long proof.

Yes, we noticed!

Page 32: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

32

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Another history1700 Leibniz1850 Babbage1920 Hilbert

Can we mechanize

mathematics?

1930 GödelTuring

Can we mechanize

mathematics?

Can we mechanize

mathematics?

Proof checking: yes

Proving: not quite

1950 von Neumann

1960 IBMLet’s build

those computers!

Thank you!Thank you!

Page 33: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

33

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Another history1700 Leibniz1850 Babbage1920 Hilbert

Can we mechanize

mathematics?

1930 GödelTuring

Can we mechanize

mathematics?

Can we mechanize

mathematics?

Proof checking: yes

Proving: not quite

1950 von Neumann

1960 IBMLet’s build

those computers!

John RobinCocke 1970s Milner

Proof

Assistants

Optimizing

compilers

Page 34: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

34

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Another history1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

John Cocke 1925-2002

IBM Research

Page 35: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Register Allocation

35

Procedure P (k, j)g := mem[j+12]h := k-1f := g∗he := mem [j+8]m := mem[j+16]b := mem[f]c := e+8d := ck := m+4j := breturn (d, k, j)

r1r2r3r4

registers memory

0123456789

1011121314

.

.

g

j

fe

k

h

mbc

d

Page 36: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

One history

36

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

Another history1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

John Cocke 1925-2002

IBM Research

Ashok Chandra(1948-2014)

Gregory Chaitin(1947-)

1977:

Hmm, this 4-color

theorem is interesting.

John, ask Gregory to try

Kempe’s coloring algorithm

in the register allocator

of our compiler.

Page 37: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Gregory Chaitin

I was recruited to do a coloring register allocator by John Cocke,

IBM's greatest computer architect, who needed it for his RISC project.

He mentioned that Ashok K. Chandra, also at IBM Research at that time,

had suggested recursively reducing the graph by eliminating vertices of

degree less than the number of available colors, as just one possible

component of a coloring algorithm.

I certainly remember the spectacular work your father did with Haken ... I

heard Haken give a talk on their proof soon after they had done it. But the

details of the proof escaped me. That was more Chandra's area of interest;

mine is information theory.

37

One of the most influential papers in all of computer science

Page 38: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Register Allocation Chaitin et al. 1981

38

Procedure P (k, j)g := mem[j+12]h := k-1f := g∗he := mem [j+8]m := mem[j+16]b := mem[f]c := e+8d := ck := m+4j := breturn (d, k, j)

g

f

h

e

b m c

d

k

k

j

j

Live ranges Interferences(some not shown)

InterferenceGraph

figure 11.1 from Modern Compiler Implementation in ML,Andrew W. Appel, Cambridge University Press 1998

Page 39: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Heuristic hack of Kempe’s algorithm

To mostly K-color a graph (whether planar or not!)

Is there a vertex of degree < K ?

If so:

Remove this vertex.

Color the rest of the graph with a recursive call to the algorithm.

Put the vertex back. It is adjacent to at most K-1 vertices. They use (among them) at most K-1 colors. That leaves one of your colors for this vertex.

If not:

Remove this vertex.

Color the rest of the graph with a recursive call.

Put the vertex back. It is adjacent to ≥ K vertices. How many colors do these vertices use among them?

If < K : there is an unused color to use for this vertex

If ≥ K:39

Chaitin’s

Page 40: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Heuristic hack of Kempe’s algorithm

To mostly K-color a graph (whether planar or not!)

Is there a vertex of degree < K ?

If so:

Remove this vertex.

Color the rest of the graph with a recursive call to the algorithm.

Put the vertex back. It is adjacent to at most K-1 vertices. They use (among them) at most K-1 colors. That leaves one of your colors for this vertex.

If not:

Remove this vertex.

Color the rest of the graph with a recursive call.

Put the vertex back. It is adjacent to ≥ K vertices. How many colors do these vertices use among them?

If < K : there is an unused color to use for this vertex

If ≥ K: leave this vertex uncolored.40

What? Are we allowed to do that?

Yes! This is an algorithm to

“mostly K-color” a graph.

Briggs’s version of Chaitin’s

Page 41: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

41

f

e

b m

cd

kj

h

g

Stack:

Page 42: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

42

f

e

b m

cd

kj

h

g

Stack:

This node

has degree < 3 ;

remove it!

Page 43: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

43

f

e

b m

cd

kj

h

g

Stack: cPush node c on

the stack

Page 44: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

44

f

e

b m

cd

kj

h

g

Stack: c

Removing c

lowers the degree

of nodes b and m;

that will be helpful later!

Page 45: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

45

f

e

b m

d

kj

h

g

Stack: c

This node

has degree < 3 ;

remove it!

Page 46: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

46

f

e

b m

d

kj

h

g

Stack: h c

This node

has degree < 3 ;

remove it!

Page 47: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

47

f

e

b m

d

kj

g

Stack: h c

This node

has degree < 3 ;

remove it!

Page 48: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

48

f

e

b m

d

kj

Stack: g h c

No node has degree < 3

Pick a node arbitrarily,

remove it, and

push it on the stack

Page 49: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

49

f

e

b m

d

kj

Stack: k g h c

Page 50: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

50

f

e

b m

d

j

Stack: k g h c

This node

has degree < 3 ;

remove it!

Page 51: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

51

f

e

b mj

Stack: d k g h c

This node

has degree < 3 ;

remove it!

Page 52: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

52

f

e

b m

Stack: j d k g h c

This node

has degree < 3 ;

remove it!

Page 53: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

53

e

b m

Stack: f j d k g h c

This node

has degree < 3 ;

remove it!

Page 54: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

54

b m

Stack: e f j d k g h c

This node

has degree < 3 ;

remove it!

Page 55: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

55

m

Stack: b e f j d k g h c

This node

has degree < 3 ;

remove it!

Page 56: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Example: 3-color this graph

56Stack: m b e f j d k g h c

Page 57: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

57Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Find a color for this

node that’s not already

used in an adjacent node

Page 58: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

58Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 59: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

59Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 60: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

60Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 61: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

61Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 62: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

62Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 63: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

63Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

We’re about to color node k.

This was the only one that was

degree ≥ 3 when we removed it.

Hence, it is not guaranteed that

we can find a color for it now.

But we got lucky, because

b and d have the same color!

Page 64: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

64Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 65: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

65Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Find a color for this

node that’s not already

used in an adjacent node

Page 66: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

66Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

gFind a color for this

node that’s not already

used in an adjacent node

Page 67: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Now, color the nodes in stack order

67Stack: m b e f j d k g h c

f

e

b m

cd

kj

h

g

Why did this work?Because (usually) when we removedeach node, at that time it had degree < 3.So when we put it back, it’s adjacentto at most 2 already-colored nodes.

Page 68: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Improvements to the Chaitin algorithm

68

Kempe 1879 graph coloring algorithm

Chaitin et al. 1981 register allocation by coloring

Chaitin 1982: spilling (“leave some nodes uncolored”)

Briggs et al. 1984: coalescing + improved spilling

Page 69: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Move coalescing

69

Procedure P (k, j)g := mem[j+12]h := k-1f := g∗he := mem [j+8]m := mem[j+16]b := mem[f]c := e+8d := ck := m+4j := breturn (d, k, j)

g

f

h

e

b m c

d

k

k

j

j

Live ranges InterferenceGraph

figure 11.1 from Modern Compiler Implementation in ML,Andrew W. Appel, Cambridge University Press 1998

If these nodes can be colored the same color,then you can delete the move instruction

Page 70: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Improvements to the Chaitin algorithm

70

c

e

b md

j

“Briggs reduction:”Coalesce a move edge c-d, if(1) no interference edge c-d(2) coalesced node cd has degree <K

Kempe 1879 graph coloring algorithm

Chaitin et al. 1981 register allocation by coloring

Chaitin 1982: spilling (“leave some nodes uncolored”)

Briggs et al. 1984: coalescing + improved spilling

Page 71: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Improvements to the Chaitin algorithm

Kempe 1879 graph coloring algorithm

Chaitin et al. 1981 register allocation by coloring

71

Chaitin 1982: spilling (“leave some nodes uncolored”)

Briggs et al. 1984: coalescing + improved spilling

cd

e

b mj

“Briggs reduction:”Coalesce a move edge c-d, if(1) no interference edge c-d(2) coalesced node cd has degree <K

Page 72: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Improvements to the Chaitin algorithm

Kempe 1879 graph coloring algorithm

Chaitin 1981 register allocation by coloring

72

Chaitin 1982: spilling (“leave some nodes uncolored”)

Briggs et al. 1984: coalescing + improved spilling

L. George & A.W. Appel 1996: Iterated Register Coalescing

c

e

b md

j

but also:“George reduction:”Coalesce a move edge c-d, if(1) no interference edge c-d(2) neighbors(d) ⊂ neighbors(c)

Interleave Briggs reductions with Kempe reductions

Page 73: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

73

Page 74: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Histories

74

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

K. Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

Cocke

1980 Chaitin

Briggs

4-color theorem computing

1996 L. George & A. Appel

Page 75: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Histories: Logic

75

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

K. Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

Cocke

1980 Chaitin

Briggs

4-color theorem computing

Church

Milner1977

1996 L. George & A. Appel

1970 Dijkstra, Floyd, Hoare

Page 76: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Program verification

76

David Gries1939-

Tony Hoare1934-

Robert Floyd1936-2001

Proofs (written by hand, checked by hand) about programs

Edsger Dijkstra1930-2002

Page 77: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Edinburgh LCF, the first Proof Assistant

77

1978

Construct proofs in a “proof language”by hand (like programs).

Proof-checker program (“kernel”)checks each step of the proof as youbuild it.

“Tactic” language permits you towrite programs to fill in the trivialparts of the proofs.

Robin Milner1934-2010

Page 78: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

78

Page 79: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

79

Page 80: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

80

Page 81: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

81

Page 82: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

82

Page 83: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

83

Page 84: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

84

Page 85: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Proving in a proof assistant

85

Page 86: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

What’s it good for?

Robin Milner’s observation (along with the thousands of

people who have worked in this field after 1978, including me):

Machine-checked proofs (and proof assistants) are really good for theorems about computer programs!

86

Page 87: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Landmarks of program verification

87

Xavier Leroy1968-

CompCertoptimizing C compiler

2006

Zhong Shao1968-

CertiKOSoperating system

2015

Gerwin Klein1975-seL4

operating system2013

Andrew Appel1960-

FoundationalProof-Carrying Code

2005

Verified

Software Toolchain

2014

Verified SHA/HMACcryptographic authentication

2015

a personal selection

Page 88: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Math

88

Kempe

Guthrie

Heawood

Birkhoff

Wernicke

Heesch

K. Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2006

1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

Cocke

1980 Chaitin

Briggs

1996 L. George & A. Appel

4-color theorem computing

Church

Milner1977

1990s numerous

softwareverification

Computing Logic

21st centurymore numerous!

1970 Dijkstra, Floyd, Hoare

Page 89: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Which part don’t you believe?

“Haken’s son Armin, by then a graduate student at … Berkeley, gave a lecture on the four-colour problem…. At the end, the audience split into two groups: the over-forties could not be convinced that a proof by computer was correct, while the under-forties* could not be convinced that a proof containing 700 pages of hand calculations could be correct.”

89

*By now that would be, “people under 80”

Page 90: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

91

Georges Gonthier1962-

2005 (see also Notices of the AMS 2008)

Page 91: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

“Trusted base:” 141 lines

92

Definition real_model := . . . 100 lines of Coq axiomatizing real numbers...

Definition map : Type := Definition simple_map: Type → Prop := Definition map_colorable: ℕ → map → Prop :=

Theorem four_color: ∀ R : real_model, ∀m : map R, simple_map m → map_colorable 4 m.

Proof.. . . 60,000 lines of Coq ...

Qed.

40 lines of elementary topology

Page 92: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Math

93

Kempe

Guthrie

Heawood

BirkhoffWernicke

Heesch

K. Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2005

1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

Cocke1980 Chaitin

Briggs1996 L. George

& A. Appel

4-color theorem

computing

Church

Milner1977

1990s numerous

machine-checked proof

Computing Logic

Page 93: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

94

19th European Symposium on Programming, 2010

Page 94: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Math

95

Kempe

Guthrie

Heawood

BirkhoffWernicke

Heesch

K. Appel, Haken

Robertson, Sanders,Seymour, Thomas

Gonthier

1880

1850

1904

1920

1960

1976

1996

2005

1700 Leibniz1850 Babbage1920 Hilbert

1930 GödelTuring

1950 von Neumann

1960 IBM

Cocke1980 Chaitin

Briggs1996 L. George

& A. Appel

4-color theorem

computing

Church

Milner1977

1990s numerous

machine-checked proof

Computing Logic

Blazy, Robillard, A. Appel

Page 95: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

In mathematics, as well

96

Kepler conjecture (1611):Face-centered cubic is

densest possible sphere packing

Hales proof (1998):5000 planar graphs,

each with a computerizednonlinear optimization calculation

Referees: we’re 99% sure it’s correct

•Project Director: Thomas Hales

•Project Managers: Ta Thi Hoai An, Mark Adams

•HOL Light libraries and support: John Harrison,

•Isabelle Tame Graph Classification:

Gertrud Bauer, Tobias Nipkow,

•Chief Programmer: Alexey Solovyev,

• Nonlinear inequalities: Victor Magron, Sean

McLaughlin, Roland Zumkeller,

• Linear Programming: Steven Obua,

• Microsoft Azure Cloud support: Daron Green, Joe

Pleso, Dan Synek, Wenming Ye,

•Chief Formalizer: Hoang Le Truong,

• Text formalization: Jason Rute, Dang Tat Dat, Nguyen

Tat Thang, Nguyen Quang Truong, Tran Nam Trung,

Trieu Thi Diep, Vu Khac Ky, Vuong Anh Quyen,

•Student Projects: Catalin Anghel, Matthew Wampler-Doty,

Nicholas Volker, Nguyen Duc Tam, Nguyen Duc Thinh, Vu

Quang Thanh,

•Proof Automation: Cezary Kaliszyk, Josef Urban,

•Editing: Erin Susick, Laurel Martin, Mary Johnston,

•External Advisors and Design: Freek Wiedijk, Georges Gonthier,

Jeremy Avigad, Christian Marchal,

•Institutional Support: NSF, Microsoft Azure Research, William

Benter Foundation, University of Pittsburgh, Radboud University,

Institute of Math (VAST), VIASM.

Hales et al. 2004-2014:Flyspec project- Formal verification

in HOL Light proof assistant

Thomas Hales1958-

Page 96: Graph Coloring and Machine Proofs in Computer Science ... Andrew... · Kempe’s graph-coloring algorithm To 6-color a planar graph: 1. Every planar graph has at least one vertex

Conclusions

• Graph coloring, with or without proofs, is widespread in Computer Science

• Computer-checked proofs are widespread, and important, in Computer Science

• Computer-checked proofs are even becoming important in Mathematics

98