Proving Theorems
and
Certifying Programs
with Coq
Stephan Boyer
@stepchowfun
Ask questions! Don’t be shy!
Logic
What’s a proof?
Inference rules
Example: modus ponens
If A → B and A then B.
“→” means “implies”
Inference rules
Example: modus ponens
If Stephan is at LambdaConf
→ Stephan is in Boulder
and Stephan is at LambdaConf
then Stephan is in Boulder.
Programming
Inference rules
Example: function application
If f : A → B and x : A
then f(x) : B.
“→” is the type constructor for functions
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.
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
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
Curry–Howard correspondence
Logic Programming
propositions ≅ types
proofs ≅ programs
Coq
Coq
“Rooster” in French
Follow along: https://github.com/stepchowfun/coq-intro