1 of 16

Proving Theorems

and

Certifying Programs

with Coq

Stephan Boyer

@stepchowfun

2 of 16

Ask questions! Don’t be shy!

3 of 16

Logic

4 of 16

What’s a proof?

  • Informally: an argument for the truth of a proposition
  • Formally: a chain of applications of inference rules starting from axioms

5 of 16

Inference rules

Example: modus ponens

If A → B and A then B.

” means “implies

6 of 16

Inference rules

Example: modus ponens

If Stephan is at LambdaConf

→ Stephan is in Boulder

and Stephan is at LambdaConf

then Stephan is in Boulder.

7 of 16

Programming

8 of 16

Inference rules

Example: function application

If f : A → B and x : A

then f(x) : B.

” is the type constructor for functions

9 of 16

Modus ponens ≅ function application

Modus ponens (logic)

If A → B and A

then B.

Application (programming)

If f : A → B and x : A

then f(x) : B.

10 of 16

Modus ponens ≅ function application

Modus ponens (logic)

If f : A → B and x : A

then f(x) : B.

f, x, and f(x) are proofs

Application (programming)

If f : A → B and x : A

then f(x) : B.

f, x, and f(x) are programs

11 of 16

Conjunctions ≅ products

Conjunction (logic)

If p : A ∧ B then p1 : A.

If p : A ∧ B then p2 : B.

p, p1, and p2 are proofs

Product (programming)

If p : (A, B) then p1 : A.

If p : (A, B) then p2 : B.

p, p1, and p2 are programs

12 of 16

Curry–Howard correspondence

Logic Programming

propositions ≅ types

proofs ≅ programs

13 of 16

Coq

14 of 16

Coq

“Rooster” in French

  • A small pure functional programming language (Gallina)
  • A scripting language for proof automation (Ltac)
  • Proof scripts don’t need to be trusted!

15 of 16

16 of 16